I have to create a java class(es) (with appropriate methods) to manage employees
ID: 3581306 • Letter: I
Question
I have to create a java class(es) (with appropriate methods) to manage employees for a small coffee shop. All classes should have at least a null constructor and copy constructor. Other constructors would be up to your discretion. Include all necessary accessors and modifiers. To test your classes, create a Container class with simply a main() method. The Container class will have attributes that are class objects of each of the classes you create. The main() method will create the class objects, perform some normal business for that store, and produce appropriate output, like:
Time Card Check – this method will check to see if the employee worked anyhours this week
Time Card Add – this method will add hours to the employees time cardc.
Time Card Total – this method will return the total hours worked by an employeed.
Employee Shift – this method will assign employees to a number of shiftse.
Empty Shifts – this method will determine if any shift is emptyf.
Shift Add – This will add an employee to a shiftg.
Shift Min – this method will set the minimum number of workers needed for a shift
Also I would really appreciate if you could use comments throught out the code so i understand.
thank you so much!!!:)
Explanation / Answer
public class TimeCard
{
public enum DayOfWeek
{
MONDAY, TUESDAY, WEDNESDAY, THURSDAY, FRIDAY, SATURDAY, SUNDAY;
}
private double[] card;
public TimeCard(double[] a){
card = a;
}
public TimeCard()
{
card = new double[] {0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0};
}
public double getHours(DayOfWeek day)
{
return this.card[day.ordinal()-1];
}
public double[] getHours()
{
double[] hrs = new double[7];
hrs = this.card;
return hrs;
}
public void updateHours(DayOfWeek day, double hrs)
{
this.card[day.ordinal()] += hrs;
}
public String toString()
{
String dowString = "";
for(DayOfWeek dow: DayOfWeek.values()){
dowString = dow.toString() + ": " + getHours(dow) ;
}
return dowString;
}
}