/** * Creates objects to hold websites. Allows the viewing of the most profitable website, * and the website user's currently on specific holidays. * * @George Wilkinson * @28/11/23 */ import java.util.ArrayList; public class Company { // Instanciate a new ArrayList to hold all the websites. private ArrayList websiteList = new ArrayList(); // Holds the value of the company name. private String name; /** * Constructor for objects of class Company */ public Company( String name ) { this.name = name; } /** * Default constructor for objects of class Company */ public Company() { name = "The Company"; } /** * Returns the name of the company. */ public String getName() { return name; } /** * Returns the list elements of websiteList. */ public ArrayList getWebsiteList() { return websiteList; } /** * Set the name of the company to a new value. */ public void setName( String name ) { this.name = name; } /** * Store a website in the websiteList */ public void storeWebsite( Website website ) { websiteList.add( website ); } /** * Returns the most profitable sites, of which are above a specified threshold * of earnings. */ public ArrayList findProfitableWebsites( int threshold ) { ArrayList profitableSites = new ArrayList(); for( Website website : websiteList ) { if( website.getSalesTotal() > threshold ) profitableSites.add( website ); } return profitableSites; } /** * Returns the members currently on any given holiday within the company, across * all websites. */ public ArrayList findMembersHoliday( Holiday holiday ) { ArrayList membersOnHoliday = new ArrayList(); for( Website website : websiteList ) { for( Member member : website.getLoggedInList() ) { if( member.getHoliday().getRefNumber().equals( holiday.getRefNumber() ) ) membersOnHoliday.add( member ); } } return membersOnHoliday; } }