Files
G4G0-1/Semester 1/Programming 1/Homework 4/Company.java
2024-01-15 20:14:10 +00:00

101 lines
2.3 KiB
Java

/**
* 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<Website> websiteList = new ArrayList<Website>();
// 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<Website> 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<Website> findProfitableWebsites( int threshold )
{
ArrayList<Website> profitableSites = new ArrayList<Website>();
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<Member> findMembersHoliday( Holiday holiday )
{
ArrayList<Member> membersOnHoliday = new ArrayList<Member>();
for( Website website : websiteList )
{
for( Member member : website.getLoggedInList() )
{
if( member.getHoliday().getRefNumber().equals( holiday.getRefNumber() ) )
membersOnHoliday.add( member );
}
}
return membersOnHoliday;
}
}