ryanbecker24
asked on
How do I display weekly shift data?
For each shift display the following information: day, shift (i.e., day or night), names and position of employees who worked during that shift (i.e., production worker or shift supervisor), and whether the production goals were met during this shift.
Sorry for all the code, this is a huge project.
TestAll class:
import java.util.ArrayList;
import java.util.Random;
/**
* Write a description of class TestAll here.
*
* @author (your name)
* @version (a version number or a date)
*/
public class TestAll
{
protected Random generator;
protected ArrayList<Employee> employees;
protected boolean metProductionGoals;
public enum WeekDay {Monday, Tuesday, Wednesday, Thursday, Friday, Saturday, Sunday};
protected static String[] names = {"Ryan","Jones","Brown","P eter","Emm a","Jennif er","Court ney",
"Ross","Joe","Chandler","R uth","Stew art","Moni ca","Rache l","Stewie ","Chris", "Meg","Lou is",
"Cleveland","Quagmire"};
protected ArrayList<ProductionWorker > pw;
protected ArrayList<ShiftSuperVisor> sv;
protected ArrayList<Manager> m;
/**
* Constructor for objects of class TestAll
*/
public TestAll()
{
pw = new ArrayList<ProductionWorker >();
sv = new ArrayList<ShiftSuperVisor> ();
m = new ArrayList<Manager>();
for(int i = 1; i <=10; i++)
{
pw.add(ProductionWorker.ge tProductio nWorker()) ;
pw.add(Shift.getProduction Goals());
pw.add(Shift.shiftDay());
pw.add(Shift.getDay());
}
System.out.println("Produc tion Worker " + pw);
for(int j = 1; j <= 10; j++)
{
sv.add(ShiftSuperVisor.get ShiftSuper Visor());
sv.add(Shift.getProduction Goals());
sv.add(Shift.shiftDay());
sv.add(Shift.getDay());
}
System.out.println("Shift Super Visor " + sv);
for(int k = 1; k <= 10; k++)
{
m.add(Manager.getManager() );
m.add(Shift.getProductionG oals());
m.add(Shift.shiftDay());
m.add(Shift.getDay());
}
System.out.println("Manage r " + m);
}
}
Employee class:
import java.util.Random;
import java.text.DecimalFormat;
import java.text.NumberFormat;
public class Employee
{
protected String eName;
protected String eNumber;
protected int hireYear;
protected double weeklySalary;
static Random generator = new Random();
static NumberFormat strFormat = new DecimalFormat("#####.00"); ;
public Employee(String eName, String eNumber, int hireYear, double weeklySalary)
{
this.eName = eName;
if(validateENumber(eNumber ))
{
this.eNumber = eNumber;
}
else
{
employeeNumber();
}
this.hireYear = hireYear;
this.weeklySalary = weeklySalary;
}
public boolean validateENumber(String eNumber)
{
boolean validate = true;
if(eNumber.length() < 5)
validate = false;
else{
for (int i = 0; i < 3; i++)
{
if(!Character.isDigit(eNum ber.charAt (i)))
{
validate = false;
}
}
if (!(eNumber.charAt(3) == '-'))
validate = false;
if (!((eNumber.charAt(4) >= 65) && (eNumber.charAt(4) <=77)))
validate = false;
}
return validate;
}
public int getHireYear()
{
return hireYear;
}
public double getWeeklySalary()
{
return weeklySalary;
}
public void setName(String name)
{
eName = name;
}
public void setHireYear(int year)
{
hireYear = year;
}
public void setWeeeklyPay(int salary)
{
weeklySalary = salary;
}
public String getName()
{
return eName;
}
public String toString()
{
return ("\n\nName: \t" + eName + "\n ID: \t" + eNumber + "\n Year Hired:\t" + hireYear +
"\n WeeklySalary:\t$" + strFormat.format(getWeekly Salary())) ;
}
public String getNumber()
{
return eNumber;
}
public static String employeeNumber()
{
int eNumber = generator.nextInt(10)* 100 + generator.nextInt(10)* 10 + generator.nextInt(10);
String enumS = "" + eNumber;
while(enumS.length() < 3)
enumS = "0" + enumS;
String let = "" + ("ABCDEFGHIJKLM").charAt(g enerator.n extInt(13) );
return enumS + "-" + let;
}
public boolean equals(Employee other)
{
if ((eName.equals(other.getNa me())) && (eNumber.equals(other.getN umber())) && (hireYear == other.getHireYear()) && (weeklySalary == other.getWeeklySalary()))
return true;
else
return false;
}
public double getSalary()
{
return weeklySalary;
}
}
ShiftSuperVisor class:
import java.util.*;
public class ShiftSuperVisor extends Employee implements SalariedEmployee
{
// instance variables - replace the example below with your own
protected double yearlySalary;
protected static double weeklySalary;
protected Random generator;
protected static String[] names = {"Katarina", "Amelia", "William", "Hope", "Isaac", "Hollis", "Claire", "Austin", "Noah"};
protected int goal;
protected static final double minYearlySalary = 40000;
protected static final double maxYearlySalary = 80000;
protected static final double maxWeeklySalary = 10000;
//constructor that calls variables from Class Employee to create object ProductionWorker
public ShiftSuperVisor(String eName,String eNumber,int hireYear, double weeklySalary)
{
super(eName,eNumber,hireYe ar,weeklyS alary);
if(super.validateENumber(e Number))
{
this.eNumber = eNumber;
}
else
this.eNumber = employeeNumber();
this.weeklySalary = weeklySalary;
}
/**
* Constructor for objects of class ShiftSuperVisor
*/
public ShiftSuperVisor(String eName,String eNumber,int hireYear,double weeklySalary, double yearlySalary, int goals)
{
super(eName,eNumber,hireYe ar,weeklyS alary);
if(super.validateENumber(e Number))
{
this.eNumber = eNumber;
}
else
this.eNumber = employeeNumber();
this.yearlySalary = yearlySalary;
this.goal = goals;
}
public double getYearlySalary()
{
return yearlySalary;
}
public void setYearlySalary(double salary)
{
this.yearlySalary = salary;
}
public void setGoal(int goal)
{
this.goal = goal;
}
public int getGoal()
{
return goal;
}
public String toString()
{
return (super.toString()+"\n YearlySalary:\t$" + strFormat.format(yearlySal ary) + "\nGoals:\t" + goal);
}
/**
* Equals method
*/
public boolean equals(ShiftSuperVisor visor)
{
if(goal == visor.getGoal())
if(yearlySalary == visor.getYearlySalary())
return true;
return false;
}
public double getSalary()
{
return yearlySalary;
}
public static ShiftSuperVisor getShiftSuperVisor()
{
Random generator = new Random();
String name = names[generator.nextInt(na mes.length )];
String eNumber = Employee.employeeNumber();
int yearHired = 2011-generator.nextInt(35) ;
double yearlySalary = minYearlySalary + generator.nextDouble()*(ma xYearlySal ary-minYea rlySalary) ;
double weeklySalary = maxWeeklySalary - generator.nextDouble()*(ma xWeeklySal ary);
int goals = generator.nextInt(35) + 1;
ShiftSuperVisor pw = new ShiftSuperVisor(name, eNumber, yearHired, weeklySalary, yearlySalary, goals);
return pw;
}
public static double computeWeeklySalary()
{
Random generator = new Random();
double beforeTax = generator.nextInt(10000);
double afterTax = beforeTax - (beforeTax *.3);
return afterTax;
}
}
ProductionWorker class:
import java.util.*;
import java.text.DecimalFormat;
import java.text.NumberFormat;
public class ProductionWorker extends Employee
{
//value of how much a production worker makes hourly
protected double hourlySalary;
protected static Random generator = new Random();;
protected static String[] names = {"Ryan","Jones","Brown","P eter","Emm a","Jennif er","Court ney", "Ross","Joe","Chandler","R uth","Stew art","Moni ca","Rache l","Stewie ","Chris", "Meg","Lou is",
"Cleveland","Quagmire"};
protected static final double minHourlySalary = 6.00;
protected static final double maxHourlySalary = 50.00;
protected static final double maxWeeklySalary = 10000;
static NumberFormat strFormat = new DecimalFormat("#####.00"); ;
//constructor that calls variables from Class Employee to create object ProductionWorker
public ProductionWorker(String eName,String eNumber,int hireYear, double weeklySalary)
{
super(eName,eNumber,hireYe ar,weeklyS alary);
if(super.validateENumber(e Number))
{
this.eNumber = eNumber;
}
else
this.eNumber = employeeNumber();
this.weeklySalary = weeklySalary;
}
public ProductionWorker(String eName,String eNumber,int hireYear, double weeklySalary, double _hourlySalary)
{
super(eName, eNumber, hireYear, weeklySalary);
this.hourlySalary = _hourlySalary;
}
public double getHourlySalary()
{
return hourlySalary;
}
public void setHourlySalary(double salary)
{
this.hourlySalary = salary;
}
public String toString()
{
return super.toString() + "\n Hourly Salary:\t$" + strFormat.format(hourlySal ary);
}
/**
* Equals method
*/
public boolean equals(ProductionWorker worker)
{
if(hourlySalary == worker.getHourlySalary())
return true;
return false;
}
public double getSalary()
{
return hourlySalary;
}
public static ProductionWorker getProductionWorker()
{
String name = names[generator.nextInt(na mes.length )];
String eNumber = Employee.employeeNumber();
int yearHired = 2011-generator.nextInt(35) ;
double hourlySalary = minHourlySalary + generator.nextDouble()*(ma xHourlySal ary-minHou rlySalary) ;
double weeklySalary = maxWeeklySalary - generator.nextDouble()*(ma xWeeklySal ary);
return new ProductionWorker(name, eNumber, yearHired, weeklySalary, hourlySalary);
}
}
SalariedEmployee interface:
public interface SalariedEmployee
{
public double getYearlySalary();
public double getWeeklySalary();
}
Manager class:
import java.util.*;
public class Manager extends Employee implements SalariedEmployee
{
protected double yearlySalary;
protected Department department;
protected Random generator = new Random();
protected static String[] names = {"Caitlyn", "Laine", "Liam", "Sophia", "Charlotte", "Jackson", "Ethan", "Mason"};
protected static final double minYearlySalary = 60000;
protected static final double maxYearlySalary = 120000;
public enum Department{PayRoll, Production, Accounting, Research, Marketing};
public Manager(String eName,String eNumber,int hireYear, double weeklySalary)
{
super(eName,eNumber,hireYe ar,weeklyS alary);
if(super.validateENumber(e Number))
{
this.eNumber = eNumber;
}
else
this.eNumber = employeeNumber();
this.weeklySalary = weeklySalary;
}
/**
* Constructor for objects of class Manager
*/
public Manager(String eName,String eNumber,int hireYear, double weeklySalary, double _yearlySalary, Department _department )
{
super(eName,eNumber,hireYe ar,weeklyS alary);
this.yearlySalary = _yearlySalary;
this.department = _department;
}
public String toString()
{
return super.toString() + "\n YearlySalary: \t$" + strFormat.format(yearlySal ary) + "\n Department: \t" + department;
}
public void setYearlySalary(double salary)
{
yearlySalary = salary;
}
public double getYearlySalary()
{
return yearlySalary;
}
public Department getDepartment()
{
return department;
}
public void setDeparment(Department department)
{
this.department = department;
}
public static Manager getManager()
{
Random generator = new Random();
String name = names[generator.nextInt(na mes.length )];
String eNumber = Employee.employeeNumber();
int yearHired = 2011-generator.nextInt(35) ;
double yearlySalary = minYearlySalary + generator.nextDouble()*(ma xYearlySal ary-minYea rlySalary) ;
double weeklySalary = computeWeeklySalary();
Department[] dir = Department.values();
Department department = dir[new Random().nextInt(dir.lengt h)];
Manager ms = new Manager(name, eNumber, yearHired, weeklySalary,yearlySalary, department );
return ms;
}
public static double computeWeeklySalary()
{
Random generator = new Random();
double beforeTax = generator.nextInt(10000);
double afterTax = 0;
double yearlySalary = minYearlySalary + generator.nextDouble()*(ma xYearlySal ary-minYea rlySalary) ;
if ((yearlySalary >= 60000) && (yearlySalary <= 80000))
{
afterTax = beforeTax - (beforeTax *.35);
}
else if ((yearlySalary >= 80001) && (yearlySalary <= 100000))
{
afterTax = beforeTax - (beforeTax *.425);
}
else if ((yearlySalary >= 100001) && (yearlySalary <= 120000))
{
afterTax = beforeTax - (beforeTax *.495);
}
return afterTax;
}
}
Shift class:
import java.util.Random;
import java.util.ArrayList;
import java.util.Scanner;
public class Shift
{
private Random generator;
private ProductionWorker prodWork;
private Manager man;
private ArrayList<ProductionWorker > employee;
private ArrayList<ShiftSuperVisor> employee2;
private ArrayList<Manager> employee3;
private boolean shift;
public enum WeekDay {Monday, Tuesday, Wednesday, Thursday, Friday, Saturday, Sunday};
private int day;
private boolean metProductionGoals;
/**
* Constructor for objects of class Shift
*/
public Shift(int day, boolean shift, boolean goals)
{
employee = new ArrayList<ProductionWorker >();
employee2 = new ArrayList<ShiftSuperVisor> ();
employee3 = new ArrayList<Manager>();
for(int i = 1; i <=5; i++)
{
employee.add(ProductionWor ker.getPro ductionWor ker());
}
System.out.println("Produc tion Worker " + employee);
for(int j = 1; j <= 3; j++)
{
employee2.add(ShiftSuperVi sor.getShi ftSuperVis or());
}
System.out.println("Shift Super Visor " + employee2);
for(int k = 1; k <= 3; k++)
{
employee3.add(Manager.getM anager());
}
System.out.println("Manage r " + employee3);
this.day = day;
this.shift = shift;
metProductionGoals = goals;
}
public ArrayList<ProductionWorker > getEmployee()
{
return employee;
}
public ArrayList<ShiftSuperVisor> getEmploye e2()
{
return employee2;
}
public ArrayList<Manager>getEmplo yee3()
{
return employee3;
}
public int getDay()
{
return day;
}
public void setDay(int day)
{
this.day = day;
}
public boolean getShift()
{
return shift;
}
public boolean productionGoals()
{
Scanner keyboard = new Scanner(System.in);
System.out.println("yes or no");
String line = keyboard.nextLine();
if(line.trim().toLowerCase ().equals( "no"))
return false;
return true;
}
public boolean getProductionGoals()
{
return metProductionGoals;
}
public boolean equals(Shift otherShift)
{
if(employee.equals(otherSh ift.getEmp loyee()))
if(employee2.equals(otherS hift.getEm ployee2()) )
if(employee3.equals(otherS hift.getEm ployee3()) )
if(metProductionGoals ==(otherShift.getProductio nGoals()))
if(day == (otherShift.getDay()))
if(shift == (otherShift.getShift()))
return true;
return false;
}
/**
* An example of a method - replace this comment with your own
*
* @param y a sample parameter for a method
* @return the sum of x and y
*/
public String toString()
{
return ((day + " " + employee + " " + employee2 + " " + employee3 + " " + metProductionGoals));
}
public boolean shiftDay()
{
Scanner keyboard = new Scanner(System.in);
System.out.println("day or night");
String line = keyboard.nextLine();
if(line.trim().toLowerCase ().equals( "night"))
return false;
return true;
}
}
import java.util.ArrayList;
import java.util.Random;
import java.text.DecimalFormat;
import java.text.NumberFormat;
TestEmployeeProductionWork er class:
public class TestEmployeeProductionWork er
{
// instance variables - replace the example below with your own
protected Random generator;
protected ArrayList<ProductionWorker > ProductionEmployees;
protected static String[] names = {"Ryan","Jones","Brown","P eter","Emm a","Jennif er","Court ney",
"Ross","Joe","Chandler","R uth","Stew art","Moni ca","Rache l","Stewie ","Chris", "Meg","Lou is",
"Cleveland","Quagmire"};
protected static double minHourlySalary = 6.00;
protected static double maxHourlySalary = 50.00;
protected static double maxWeeklySalary = 10000.00;
/**
* Initializes an ArrayList of 20 employees to a reasonable but random values
* (you may use class Random to generate the values).
*/
public TestEmployeeProductionWork er()
{
ProductionEmployees = new ArrayList<ProductionWorker >();
for(int i = 1; i <= 20; i++)
{
ProductionEmployees.add(ge tProductio nWorker()) ;
}
System.out.println(Product ionEmploye es);
}
public static ProductionWorker getProductionWorker()
{
Random generator = new Random();
String name = names[generator.nextInt(na mes.length )];
String eNumber = Employee.employeeNumber();
int yearHired = 2011-generator.nextInt(35) ;
double hourlySalary = minHourlySalary + Math.random()*(maxHourlySa lary-minHo urlySalary );
double weeklySalary = maxWeeklySalary - Math.random()*(maxWeeklySa lary);
ProductionWorker pw = new ProductionWorker(name, eNumber, yearHired, hourlySalary, weeklySalary);
return pw;
}
}
Sorry for all the code, this is a huge project.
TestAll class:
import java.util.ArrayList;
import java.util.Random;
/**
* Write a description of class TestAll here.
*
* @author (your name)
* @version (a version number or a date)
*/
public class TestAll
{
protected Random generator;
protected ArrayList<Employee> employees;
protected boolean metProductionGoals;
public enum WeekDay {Monday, Tuesday, Wednesday, Thursday, Friday, Saturday, Sunday};
protected static String[] names = {"Ryan","Jones","Brown","P
"Ross","Joe","Chandler","R
"Cleveland","Quagmire"};
protected ArrayList<ProductionWorker
protected ArrayList<ShiftSuperVisor>
protected ArrayList<Manager> m;
/**
* Constructor for objects of class TestAll
*/
public TestAll()
{
pw = new ArrayList<ProductionWorker
sv = new ArrayList<ShiftSuperVisor>
m = new ArrayList<Manager>();
for(int i = 1; i <=10; i++)
{
pw.add(ProductionWorker.ge
pw.add(Shift.getProduction
pw.add(Shift.shiftDay());
pw.add(Shift.getDay());
}
System.out.println("Produc
for(int j = 1; j <= 10; j++)
{
sv.add(ShiftSuperVisor.get
sv.add(Shift.getProduction
sv.add(Shift.shiftDay());
sv.add(Shift.getDay());
}
System.out.println("Shift Super Visor " + sv);
for(int k = 1; k <= 10; k++)
{
m.add(Manager.getManager()
m.add(Shift.getProductionG
m.add(Shift.shiftDay());
m.add(Shift.getDay());
}
System.out.println("Manage
}
}
Employee class:
import java.util.Random;
import java.text.DecimalFormat;
import java.text.NumberFormat;
public class Employee
{
protected String eName;
protected String eNumber;
protected int hireYear;
protected double weeklySalary;
static Random generator = new Random();
static NumberFormat strFormat = new DecimalFormat("#####.00");
public Employee(String eName, String eNumber, int hireYear, double weeklySalary)
{
this.eName = eName;
if(validateENumber(eNumber
{
this.eNumber = eNumber;
}
else
{
employeeNumber();
}
this.hireYear = hireYear;
this.weeklySalary = weeklySalary;
}
public boolean validateENumber(String eNumber)
{
boolean validate = true;
if(eNumber.length() < 5)
validate = false;
else{
for (int i = 0; i < 3; i++)
{
if(!Character.isDigit(eNum
{
validate = false;
}
}
if (!(eNumber.charAt(3) == '-'))
validate = false;
if (!((eNumber.charAt(4) >= 65) && (eNumber.charAt(4) <=77)))
validate = false;
}
return validate;
}
public int getHireYear()
{
return hireYear;
}
public double getWeeklySalary()
{
return weeklySalary;
}
public void setName(String name)
{
eName = name;
}
public void setHireYear(int year)
{
hireYear = year;
}
public void setWeeeklyPay(int salary)
{
weeklySalary = salary;
}
public String getName()
{
return eName;
}
public String toString()
{
return ("\n\nName: \t" + eName + "\n ID: \t" + eNumber + "\n Year Hired:\t" + hireYear +
"\n WeeklySalary:\t$" + strFormat.format(getWeekly
}
public String getNumber()
{
return eNumber;
}
public static String employeeNumber()
{
int eNumber = generator.nextInt(10)* 100 + generator.nextInt(10)* 10 + generator.nextInt(10);
String enumS = "" + eNumber;
while(enumS.length() < 3)
enumS = "0" + enumS;
String let = "" + ("ABCDEFGHIJKLM").charAt(g
return enumS + "-" + let;
}
public boolean equals(Employee other)
{
if ((eName.equals(other.getNa
return true;
else
return false;
}
public double getSalary()
{
return weeklySalary;
}
}
ShiftSuperVisor class:
import java.util.*;
public class ShiftSuperVisor extends Employee implements SalariedEmployee
{
// instance variables - replace the example below with your own
protected double yearlySalary;
protected static double weeklySalary;
protected Random generator;
protected static String[] names = {"Katarina", "Amelia", "William", "Hope", "Isaac", "Hollis", "Claire", "Austin", "Noah"};
protected int goal;
protected static final double minYearlySalary = 40000;
protected static final double maxYearlySalary = 80000;
protected static final double maxWeeklySalary = 10000;
//constructor that calls variables from Class Employee to create object ProductionWorker
public ShiftSuperVisor(String eName,String eNumber,int hireYear, double weeklySalary)
{
super(eName,eNumber,hireYe
if(super.validateENumber(e
{
this.eNumber = eNumber;
}
else
this.eNumber = employeeNumber();
this.weeklySalary = weeklySalary;
}
/**
* Constructor for objects of class ShiftSuperVisor
*/
public ShiftSuperVisor(String eName,String eNumber,int hireYear,double weeklySalary, double yearlySalary, int goals)
{
super(eName,eNumber,hireYe
if(super.validateENumber(e
{
this.eNumber = eNumber;
}
else
this.eNumber = employeeNumber();
this.yearlySalary = yearlySalary;
this.goal = goals;
}
public double getYearlySalary()
{
return yearlySalary;
}
public void setYearlySalary(double salary)
{
this.yearlySalary = salary;
}
public void setGoal(int goal)
{
this.goal = goal;
}
public int getGoal()
{
return goal;
}
public String toString()
{
return (super.toString()+"\n YearlySalary:\t$" + strFormat.format(yearlySal
}
/**
* Equals method
*/
public boolean equals(ShiftSuperVisor visor)
{
if(goal == visor.getGoal())
if(yearlySalary == visor.getYearlySalary())
return true;
return false;
}
public double getSalary()
{
return yearlySalary;
}
public static ShiftSuperVisor getShiftSuperVisor()
{
Random generator = new Random();
String name = names[generator.nextInt(na
String eNumber = Employee.employeeNumber();
int yearHired = 2011-generator.nextInt(35)
double yearlySalary = minYearlySalary + generator.nextDouble()*(ma
double weeklySalary = maxWeeklySalary - generator.nextDouble()*(ma
int goals = generator.nextInt(35) + 1;
ShiftSuperVisor pw = new ShiftSuperVisor(name, eNumber, yearHired, weeklySalary, yearlySalary, goals);
return pw;
}
public static double computeWeeklySalary()
{
Random generator = new Random();
double beforeTax = generator.nextInt(10000);
double afterTax = beforeTax - (beforeTax *.3);
return afterTax;
}
}
ProductionWorker class:
import java.util.*;
import java.text.DecimalFormat;
import java.text.NumberFormat;
public class ProductionWorker extends Employee
{
//value of how much a production worker makes hourly
protected double hourlySalary;
protected static Random generator = new Random();;
protected static String[] names = {"Ryan","Jones","Brown","P
"Cleveland","Quagmire"};
protected static final double minHourlySalary = 6.00;
protected static final double maxHourlySalary = 50.00;
protected static final double maxWeeklySalary = 10000;
static NumberFormat strFormat = new DecimalFormat("#####.00");
//constructor that calls variables from Class Employee to create object ProductionWorker
public ProductionWorker(String eName,String eNumber,int hireYear, double weeklySalary)
{
super(eName,eNumber,hireYe
if(super.validateENumber(e
{
this.eNumber = eNumber;
}
else
this.eNumber = employeeNumber();
this.weeklySalary = weeklySalary;
}
public ProductionWorker(String eName,String eNumber,int hireYear, double weeklySalary, double _hourlySalary)
{
super(eName, eNumber, hireYear, weeklySalary);
this.hourlySalary = _hourlySalary;
}
public double getHourlySalary()
{
return hourlySalary;
}
public void setHourlySalary(double salary)
{
this.hourlySalary = salary;
}
public String toString()
{
return super.toString() + "\n Hourly Salary:\t$" + strFormat.format(hourlySal
}
/**
* Equals method
*/
public boolean equals(ProductionWorker worker)
{
if(hourlySalary == worker.getHourlySalary())
return true;
return false;
}
public double getSalary()
{
return hourlySalary;
}
public static ProductionWorker getProductionWorker()
{
String name = names[generator.nextInt(na
String eNumber = Employee.employeeNumber();
int yearHired = 2011-generator.nextInt(35)
double hourlySalary = minHourlySalary + generator.nextDouble()*(ma
double weeklySalary = maxWeeklySalary - generator.nextDouble()*(ma
return new ProductionWorker(name, eNumber, yearHired, weeklySalary, hourlySalary);
}
}
SalariedEmployee interface:
public interface SalariedEmployee
{
public double getYearlySalary();
public double getWeeklySalary();
}
Manager class:
import java.util.*;
public class Manager extends Employee implements SalariedEmployee
{
protected double yearlySalary;
protected Department department;
protected Random generator = new Random();
protected static String[] names = {"Caitlyn", "Laine", "Liam", "Sophia", "Charlotte", "Jackson", "Ethan", "Mason"};
protected static final double minYearlySalary = 60000;
protected static final double maxYearlySalary = 120000;
public enum Department{PayRoll, Production, Accounting, Research, Marketing};
public Manager(String eName,String eNumber,int hireYear, double weeklySalary)
{
super(eName,eNumber,hireYe
if(super.validateENumber(e
{
this.eNumber = eNumber;
}
else
this.eNumber = employeeNumber();
this.weeklySalary = weeklySalary;
}
/**
* Constructor for objects of class Manager
*/
public Manager(String eName,String eNumber,int hireYear, double weeklySalary, double _yearlySalary, Department _department )
{
super(eName,eNumber,hireYe
this.yearlySalary = _yearlySalary;
this.department = _department;
}
public String toString()
{
return super.toString() + "\n YearlySalary: \t$" + strFormat.format(yearlySal
}
public void setYearlySalary(double salary)
{
yearlySalary = salary;
}
public double getYearlySalary()
{
return yearlySalary;
}
public Department getDepartment()
{
return department;
}
public void setDeparment(Department department)
{
this.department = department;
}
public static Manager getManager()
{
Random generator = new Random();
String name = names[generator.nextInt(na
String eNumber = Employee.employeeNumber();
int yearHired = 2011-generator.nextInt(35)
double yearlySalary = minYearlySalary + generator.nextDouble()*(ma
double weeklySalary = computeWeeklySalary();
Department[] dir = Department.values();
Department department = dir[new Random().nextInt(dir.lengt
Manager ms = new Manager(name, eNumber, yearHired, weeklySalary,yearlySalary,
return ms;
}
public static double computeWeeklySalary()
{
Random generator = new Random();
double beforeTax = generator.nextInt(10000);
double afterTax = 0;
double yearlySalary = minYearlySalary + generator.nextDouble()*(ma
if ((yearlySalary >= 60000) && (yearlySalary <= 80000))
{
afterTax = beforeTax - (beforeTax *.35);
}
else if ((yearlySalary >= 80001) && (yearlySalary <= 100000))
{
afterTax = beforeTax - (beforeTax *.425);
}
else if ((yearlySalary >= 100001) && (yearlySalary <= 120000))
{
afterTax = beforeTax - (beforeTax *.495);
}
return afterTax;
}
}
Shift class:
import java.util.Random;
import java.util.ArrayList;
import java.util.Scanner;
public class Shift
{
private Random generator;
private ProductionWorker prodWork;
private Manager man;
private ArrayList<ProductionWorker
private ArrayList<ShiftSuperVisor>
private ArrayList<Manager> employee3;
private boolean shift;
public enum WeekDay {Monday, Tuesday, Wednesday, Thursday, Friday, Saturday, Sunday};
private int day;
private boolean metProductionGoals;
/**
* Constructor for objects of class Shift
*/
public Shift(int day, boolean shift, boolean goals)
{
employee = new ArrayList<ProductionWorker
employee2 = new ArrayList<ShiftSuperVisor>
employee3 = new ArrayList<Manager>();
for(int i = 1; i <=5; i++)
{
employee.add(ProductionWor
}
System.out.println("Produc
for(int j = 1; j <= 3; j++)
{
employee2.add(ShiftSuperVi
}
System.out.println("Shift Super Visor " + employee2);
for(int k = 1; k <= 3; k++)
{
employee3.add(Manager.getM
}
System.out.println("Manage
this.day = day;
this.shift = shift;
metProductionGoals = goals;
}
public ArrayList<ProductionWorker
{
return employee;
}
public ArrayList<ShiftSuperVisor>
{
return employee2;
}
public ArrayList<Manager>getEmplo
{
return employee3;
}
public int getDay()
{
return day;
}
public void setDay(int day)
{
this.day = day;
}
public boolean getShift()
{
return shift;
}
public boolean productionGoals()
{
Scanner keyboard = new Scanner(System.in);
System.out.println("yes or no");
String line = keyboard.nextLine();
if(line.trim().toLowerCase
return false;
return true;
}
public boolean getProductionGoals()
{
return metProductionGoals;
}
public boolean equals(Shift otherShift)
{
if(employee.equals(otherSh
if(employee2.equals(otherS
if(employee3.equals(otherS
if(metProductionGoals ==(otherShift.getProductio
if(day == (otherShift.getDay()))
if(shift == (otherShift.getShift()))
return true;
return false;
}
/**
* An example of a method - replace this comment with your own
*
* @param y a sample parameter for a method
* @return the sum of x and y
*/
public String toString()
{
return ((day + " " + employee + " " + employee2 + " " + employee3 + " " + metProductionGoals));
}
public boolean shiftDay()
{
Scanner keyboard = new Scanner(System.in);
System.out.println("day or night");
String line = keyboard.nextLine();
if(line.trim().toLowerCase
return false;
return true;
}
}
import java.util.ArrayList;
import java.util.Random;
import java.text.DecimalFormat;
import java.text.NumberFormat;
TestEmployeeProductionWork
public class TestEmployeeProductionWork
{
// instance variables - replace the example below with your own
protected Random generator;
protected ArrayList<ProductionWorker
protected static String[] names = {"Ryan","Jones","Brown","P
"Ross","Joe","Chandler","R
"Cleveland","Quagmire"};
protected static double minHourlySalary = 6.00;
protected static double maxHourlySalary = 50.00;
protected static double maxWeeklySalary = 10000.00;
/**
* Initializes an ArrayList of 20 employees to a reasonable but random values
* (you may use class Random to generate the values).
*/
public TestEmployeeProductionWork
{
ProductionEmployees = new ArrayList<ProductionWorker
for(int i = 1; i <= 20; i++)
{
ProductionEmployees.add(ge
}
System.out.println(Product
}
public static ProductionWorker getProductionWorker()
{
Random generator = new Random();
String name = names[generator.nextInt(na
String eNumber = Employee.employeeNumber();
int yearHired = 2011-generator.nextInt(35)
double hourlySalary = minHourlySalary + Math.random()*(maxHourlySa
double weeklySalary = maxWeeklySalary - Math.random()*(maxWeeklySa
ProductionWorker pw = new ProductionWorker(name, eNumber, yearHired, hourlySalary, weeklySalary);
return pw;
}
}
ASKER
for the manager,productionworker,a nd shiftsupervisor to display the production goals, if its day or night, day of the week
No you cannot do it
pw is ArrayList of ProductionWorkers
getProdcutionGoals() ireturns boolean, there is no way
you can add to ArrayList of ProductionWorkeres boolean value
Maybe you can change property of ProdctionWorker and then add instance of ProductionWorker
but you cannot add boolean
To arraylist pw you can only add instances of ProductionWorkers
The code is too big for me to undersatnd easily logic
especially when it is not working...
pw is ArrayList of ProductionWorkers
getProdcutionGoals() ireturns boolean, there is no way
you can add to ArrayList of ProductionWorkeres boolean value
Maybe you can change property of ProdctionWorker and then add instance of ProductionWorker
but you cannot add boolean
To arraylist pw you can only add instances of ProductionWorkers
The code is too big for me to undersatnd easily logic
especially when it is not working...
ASKER
i tried to change getProductionGoals() to int but i get a static problem
Note: it might help if you attached your code as a file. (File|Code|Image|Screencas t) If it's more than one file, make a zip file out of it. Some comments might help too especially around areas that don't work.
>i tried to change getProductionGoals() to int but i get a static problem
that's is another problem that method looks like static
but please befoer everuything like that think about the logic:
pw = new ArrayList<ProductionWorker
this says tah pw is ArrayList of ProductionWorkeres
this line is fine - you are adding and element which is instance of ProductionWorker
pw.add(ProductionWorker.ge
the next lines just make no logical sense - you cannot add anyhting ele to this arraylist - nor boolean, nor integer
the only think you can add is instance of ProductionWorker
What is it you are truying to do?
Yes you can say that say this instance of priodcution woorker has boolean property and you can set that boolean
property but when adding to ArrayLyist pw you should be adding only ProduictionWorkers
Please, explain in words what you want to do and maybe we will understabnd something
For_yan asked What is it you are truying to do?
I agree. It would help to have more comments in your program to tell us what you are trying to accomplish. (Some "theoretical" background of what's in your head.)
I agree. It would help to have more comments in your program to tell us what you are trying to accomplish. (Some "theoretical" background of what's in your head.)
ASKER
I am trying to create a list of production workers that have a name,number,yearhired,week lysalary,h ourlysalar y,if its day or night,day of week,if they met there production goals. the managers have name,number,yearhired,week lysalary,h ourlysalar y,departme nt. shiftsupervisor has name,number,yearhired,week lysalary,h ourlysalar y,goals.
So you first need to create all those folks maybe wioth constrcutors or with suvch methods like here
ProductionWorker.getProduc tionWorker ());
ansd when it creates them it should probably randndomly(?) - it was that way in the beginning of your applucation -
assign all thos properies - then
you add instances of those people to respcetive arraylists - but your oproperties cannot exist by itself - thery
are propertuyes of peopel and thios people can beadded to the ArraylIsts corresponding to thier postions
So no boolean no integers - only workeres are elemants of array lists
ProductionWorker.getProduc
ansd when it creates them it should probably randndomly(?) - it was that way in the beginning of your applucation -
assign all thos properies - then
you add instances of those people to respcetive arraylists - but your oproperties cannot exist by itself - thery
are propertuyes of peopel and thios people can beadded to the ArraylIsts corresponding to thier postions
So no boolean no integers - only workeres are elemants of array lists
This at least pworks and produce output
We need to add shifts and met goals or something
(I just removed adding boolena to people,
and with that it compiles and works) - see output
We need to add shifts and met goals or something
(I just removed adding boolena to people,
and with that it compiles and works) - see output
import java.text.DecimalFormat;
import java.text.NumberFormat;
import java.util.ArrayList;
import java.util.Random;
import java.util.Scanner;
/**
* Write a description of class TestAll here.
*
* @author (your name)
* @version (a version number or a date)
*/
public class TestAll
{
protected Random generator;
protected ArrayList<Employee> employees;
protected boolean metProductionGoals;
public enum WeekDay {Monday, Tuesday, Wednesday, Thursday, Friday, Saturday, Sunday};
protected static String[] names = {"Ryan","Jones","Brown","Peter","Emma","Jennifer","Courtney",
"Ross","Joe","Chandler","Ruth","Stewart","Monica","Rachel","Stewie","Chris","Meg","Louis",
"Cleveland","Quagmire"};
protected ArrayList<ProductionWorker> pw;
protected ArrayList<ShiftSuperVisor> sv;
protected ArrayList<Manager> m;
/**
* Constructor for objects of class TestAll
*/
public TestAll()
{
pw = new ArrayList<ProductionWorker>();
sv = new ArrayList<ShiftSuperVisor>();
m = new ArrayList<Manager>();
for(int i = 1; i <=10; i++)
{
pw.add(ProductionWorker.getProductionWorker());
// pw.add(Shift.getProductionGoals());
//pw.add(Shift.shiftDay());
// pw.add(Shift.getDay());
}
System.out.println("Production Worker " + pw);
for(int j = 1; j <= 10; j++)
{
sv.add(ShiftSuperVisor.getShiftSuperVisor());
// sv.add(Shift.getProductionGoals());
// sv.add(Shift.shiftDay());
// sv.add(Shift.getDay());
}
System.out.println("Shift Super Visor " + sv);
for(int k = 1; k <= 10; k++)
{
m.add(Manager.getManager());
// m.add(Shift.getProductionGoals());
// m.add(Shift.shiftDay());
// m.add(Shift.getDay());
}
System.out.println("Manager " + m);
}
public static void main(String[] args) {
new TestAll();
}
}
class Employee
{
protected String eName;
protected String eNumber;
protected int hireYear;
protected double weeklySalary;
static Random generator = new Random();
static NumberFormat strFormat = new DecimalFormat("#####.00");;
public Employee(String eName, String eNumber, int hireYear, double weeklySalary)
{
this.eName = eName;
if(validateENumber(eNumber))
{
this.eNumber = eNumber;
}
else
{
employeeNumber();
}
this.hireYear = hireYear;
this.weeklySalary = weeklySalary;
}
public boolean validateENumber(String eNumber)
{
boolean validate = true;
if(eNumber.length() < 5)
validate = false;
else{
for (int i = 0; i < 3; i++)
{
if(!Character.isDigit(eNumber.charAt(i)))
{
validate = false;
}
}
if (!(eNumber.charAt(3) == '-'))
validate = false;
if (!((eNumber.charAt(4) >= 65) && (eNumber.charAt(4) <=77)))
validate = false;
}
return validate;
}
public int getHireYear()
{
return hireYear;
}
public double getWeeklySalary()
{
return weeklySalary;
}
public void setName(String name)
{
eName = name;
}
public void setHireYear(int year)
{
hireYear = year;
}
public void setWeeeklyPay(int salary)
{
weeklySalary = salary;
}
public String getName()
{
return eName;
}
public String toString()
{
return ("\n\nName: \t" + eName + "\n ID: \t" + eNumber + "\n Year Hired:\t" + hireYear +
"\n WeeklySalary:\t$" + strFormat.format(getWeeklySalary()));
}
public String getNumber()
{
return eNumber;
}
public static String employeeNumber()
{
int eNumber = generator.nextInt(10)* 100 + generator.nextInt(10)* 10 + generator.nextInt(10);
String enumS = "" + eNumber;
while(enumS.length() < 3)
enumS = "0" + enumS;
String let = "" + ("ABCDEFGHIJKLM").charAt(generator.nextInt(13));
return enumS + "-" + let;
}
public boolean equals(Employee other)
{
if ((eName.equals(other.getName())) && (eNumber.equals(other.getNumber())) && (hireYear == other.getHireYear()) && (weeklySalary == other.getWeeklySalary()))
return true;
else
return false;
}
public double getSalary()
{
return weeklySalary;
}
}
class ShiftSuperVisor extends Employee implements SalariedEmployee
{
// instance variables - replace the example below with your own
protected double yearlySalary;
protected static double weeklySalary;
protected Random generator;
protected static String[] names = {"Katarina", "Amelia", "William", "Hope", "Isaac", "Hollis", "Claire", "Austin", "Noah"};
protected int goal;
protected static final double minYearlySalary = 40000;
protected static final double maxYearlySalary = 80000;
protected static final double maxWeeklySalary = 10000;
//constructor that calls variables from Class Employee to create object ProductionWorker
public ShiftSuperVisor(String eName,String eNumber,int hireYear, double weeklySalary)
{
super(eName,eNumber,hireYear,weeklySalary);
if(super.validateENumber(eNumber))
{
this.eNumber = eNumber;
}
else
this.eNumber = employeeNumber();
this.weeklySalary = weeklySalary;
}
/**
* Constructor for objects of class ShiftSuperVisor
*/
public ShiftSuperVisor(String eName,String eNumber,int hireYear,double weeklySalary, double yearlySalary, int goals)
{
super(eName,eNumber,hireYear,weeklySalary);
if(super.validateENumber(eNumber))
{
this.eNumber = eNumber;
}
else
this.eNumber = employeeNumber();
this.yearlySalary = yearlySalary;
this.goal = goals;
}
public double getYearlySalary()
{
return yearlySalary;
}
public void setYearlySalary(double salary)
{
this.yearlySalary = salary;
}
public void setGoal(int goal)
{
this.goal = goal;
}
public int getGoal()
{
return goal;
}
public String toString()
{
return (super.toString()+"\n YearlySalary:\t$" + strFormat.format(yearlySalary) + "\nGoals:\t" + goal);
}
/**
* Equals method
*/
public boolean equals(ShiftSuperVisor visor)
{
if(goal == visor.getGoal())
if(yearlySalary == visor.getYearlySalary())
return true;
return false;
}
public double getSalary()
{
return yearlySalary;
}
public static ShiftSuperVisor getShiftSuperVisor()
{
Random generator = new Random();
String name = names[generator.nextInt(names.length)];
String eNumber = Employee.employeeNumber();
int yearHired = 2011-generator.nextInt(35);
double yearlySalary = minYearlySalary + generator.nextDouble()*(maxYearlySalary-minYearlySalary);
double weeklySalary = maxWeeklySalary - generator.nextDouble()*(maxWeeklySalary);
int goals = generator.nextInt(35) + 1;
ShiftSuperVisor pw = new ShiftSuperVisor(name, eNumber, yearHired, weeklySalary, yearlySalary, goals);
return pw;
}
public static double computeWeeklySalary()
{
Random generator = new Random();
double beforeTax = generator.nextInt(10000);
double afterTax = beforeTax - (beforeTax *.3);
return afterTax;
}
}
class ProductionWorker extends Employee
{
//value of how much a production worker makes hourly
protected double hourlySalary;
protected static Random generator = new Random();;
protected static String[] names = {"Ryan","Jones","Brown","Peter","Emma","Jennifer","Courtney", "Ross","Joe","Chandler","Ruth","Stewart","Monica","Rachel","Stewie","Chris","Meg","Louis",
"Cleveland","Quagmire"};
protected static final double minHourlySalary = 6.00;
protected static final double maxHourlySalary = 50.00;
protected static final double maxWeeklySalary = 10000;
static NumberFormat strFormat = new DecimalFormat("#####.00");;
//constructor that calls variables from Class Employee to create object ProductionWorker
public ProductionWorker(String eName,String eNumber,int hireYear, double weeklySalary)
{
super(eName,eNumber,hireYear,weeklySalary);
if(super.validateENumber(eNumber))
{
this.eNumber = eNumber;
}
else
this.eNumber = employeeNumber();
this.weeklySalary = weeklySalary;
}
public ProductionWorker(String eName,String eNumber,int hireYear, double weeklySalary, double _hourlySalary)
{
super(eName, eNumber, hireYear, weeklySalary);
this.hourlySalary = _hourlySalary;
}
public double getHourlySalary()
{
return hourlySalary;
}
public void setHourlySalary(double salary)
{
this.hourlySalary = salary;
}
public String toString()
{
return super.toString() + "\n Hourly Salary:\t$" + strFormat.format(hourlySalary);
}
/**
* Equals method
*/
public boolean equals(ProductionWorker worker)
{
if(hourlySalary == worker.getHourlySalary())
return true;
return false;
}
public double getSalary()
{
return hourlySalary;
}
public static ProductionWorker getProductionWorker()
{
String name = names[generator.nextInt(names.length)];
String eNumber = Employee.employeeNumber();
int yearHired = 2011-generator.nextInt(35);
double hourlySalary = minHourlySalary + generator.nextDouble()*(maxHourlySalary-minHourlySalary);
double weeklySalary = maxWeeklySalary - generator.nextDouble()*(maxWeeklySalary);
return new ProductionWorker(name, eNumber, yearHired, weeklySalary, hourlySalary);
}
}
interface SalariedEmployee
{
public double getYearlySalary();
public double getWeeklySalary();
}
class Manager extends Employee implements SalariedEmployee
{
protected double yearlySalary;
protected Department department;
protected Random generator = new Random();
protected static String[] names = {"Caitlyn", "Laine", "Liam", "Sophia", "Charlotte", "Jackson", "Ethan", "Mason"};
protected static final double minYearlySalary = 60000;
protected static final double maxYearlySalary = 120000;
public enum Department{PayRoll, Production, Accounting, Research, Marketing};
public Manager(String eName,String eNumber,int hireYear, double weeklySalary)
{
super(eName,eNumber,hireYear,weeklySalary);
if(super.validateENumber(eNumber))
{
this.eNumber = eNumber;
}
else
this.eNumber = employeeNumber();
this.weeklySalary = weeklySalary;
}
/**
* Constructor for objects of class Manager
*/
public Manager(String eName,String eNumber,int hireYear, double weeklySalary, double _yearlySalary, Department _department )
{
super(eName,eNumber,hireYear,weeklySalary);
this.yearlySalary = _yearlySalary;
this.department = _department;
}
public String toString()
{
return super.toString() + "\n YearlySalary: \t$" + strFormat.format(yearlySalary) + "\n Department: \t" + department;
}
public void setYearlySalary(double salary)
{
yearlySalary = salary;
}
public double getYearlySalary()
{
return yearlySalary;
}
public Department getDepartment()
{
return department;
}
public void setDeparment(Department department)
{
this.department = department;
}
public static Manager getManager()
{
Random generator = new Random();
String name = names[generator.nextInt(names.length)];
String eNumber = Employee.employeeNumber();
int yearHired = 2011-generator.nextInt(35);
double yearlySalary = minYearlySalary + generator.nextDouble()*(maxYearlySalary-minYearlySalary);
double weeklySalary = computeWeeklySalary();
Department[] dir = Department.values();
Department department = dir[new Random().nextInt(dir.length)];
Manager ms = new Manager(name, eNumber, yearHired, weeklySalary,yearlySalary,department);
return ms;
}
public static double computeWeeklySalary()
{
Random generator = new Random();
double beforeTax = generator.nextInt(10000);
double afterTax = 0;
double yearlySalary = minYearlySalary + generator.nextDouble()*(maxYearlySalary-minYearlySalary);
if ((yearlySalary >= 60000) && (yearlySalary <= 80000))
{
afterTax = beforeTax - (beforeTax *.35);
}
else if ((yearlySalary >= 80001) && (yearlySalary <= 100000))
{
afterTax = beforeTax - (beforeTax *.425);
}
else if ((yearlySalary >= 100001) && (yearlySalary <= 120000))
{
afterTax = beforeTax - (beforeTax *.495);
}
return afterTax;
}
}
class Shift
{
private Random generator;
private ProductionWorker prodWork;
private Manager man;
private ArrayList<ProductionWorker> employee;
private ArrayList<ShiftSuperVisor> employee2;
private ArrayList<Manager> employee3;
private boolean shift;
public enum WeekDay {Monday, Tuesday, Wednesday, Thursday, Friday, Saturday, Sunday};
private int day;
private boolean metProductionGoals;
/**
* Constructor for objects of class Shift
*/
public Shift(int day, boolean shift, boolean goals)
{
employee = new ArrayList<ProductionWorker>();
employee2 = new ArrayList<ShiftSuperVisor>();
employee3 = new ArrayList<Manager>();
for(int i = 1; i <=5; i++)
{
employee.add(ProductionWorker.getProductionWorker());
}
System.out.println("Production Worker " + employee);
for(int j = 1; j <= 3; j++)
{
employee2.add(ShiftSuperVisor.getShiftSuperVisor());
}
System.out.println("Shift Super Visor " + employee2);
for(int k = 1; k <= 3; k++)
{
employee3.add(Manager.getManager());
}
System.out.println("Manager " + employee3);
this.day = day;
this.shift = shift;
metProductionGoals = goals;
}
public ArrayList<ProductionWorker> getEmployee()
{
return employee;
}
public ArrayList<ShiftSuperVisor>getEmployee2()
{
return employee2;
}
public ArrayList<Manager>getEmployee3()
{
return employee3;
}
public int getDay()
{
return day;
}
public void setDay(int day)
{
this.day = day;
}
public boolean getShift()
{
return shift;
}
public boolean productionGoals()
{
Scanner keyboard = new Scanner(System.in);
System.out.println("yes or no");
String line = keyboard.nextLine();
if(line.trim().toLowerCase().equals("no"))
return false;
return true;
}
public boolean getProductionGoals()
{
return metProductionGoals;
}
public boolean equals(Shift otherShift)
{
if(employee.equals(otherShift.getEmployee()))
if(employee2.equals(otherShift.getEmployee2()))
if(employee3.equals(otherShift.getEmployee3()))
if(metProductionGoals ==(otherShift.getProductionGoals()))
if(day == (otherShift.getDay()))
if(shift == (otherShift.getShift()))
return true;
return false;
}
/**
* An example of a method - replace this comment with your own
*
// * @param y a sample parameter for a method
* @return the sum of x and y
*/
public String toString()
{
return ((day + " " + employee + " " + employee2 + " " + employee3 + " " + metProductionGoals));
}
public boolean shiftDay()
{
Scanner keyboard = new Scanner(System.in);
System.out.println("day or night");
String line = keyboard.nextLine();
if(line.trim().toLowerCase().equals("night"))
return false;
return true;
}
}
class TestEmployeeProductionWorker
{
// instance variables - replace the example below with your own
protected Random generator;
protected ArrayList<ProductionWorker> ProductionEmployees;
protected static String[] names = {"Ryan","Jones","Brown","Peter","Emma","Jennifer","Courtney",
"Ross","Joe","Chandler","Ruth","Stewart","Monica","Rachel","Stewie","Chris","Meg","Louis",
"Cleveland","Quagmire"};
protected static double minHourlySalary = 6.00;
protected static double maxHourlySalary = 50.00;
protected static double maxWeeklySalary = 10000.00;
/**
* Initializes an ArrayList of 20 employees to a reasonable but random values
* (you may use class Random to generate the values).
*/
public TestEmployeeProductionWorker()
{
ProductionEmployees = new ArrayList<ProductionWorker>();
for(int i = 1; i <= 20; i++)
{
ProductionEmployees.add(getProductionWorker());
}
System.out.println(ProductionEmployees);
}
public static ProductionWorker getProductionWorker()
{
Random generator = new Random();
String name = names[generator.nextInt(names.length)];
String eNumber = Employee.employeeNumber();
int yearHired = 2011-generator.nextInt(35);
double hourlySalary = minHourlySalary + Math.random()*(maxHourlySalary-minHourlySalary);
double weeklySalary = maxWeeklySalary - Math.random()*(maxWeeklySalary);
ProductionWorker pw = new ProductionWorker(name, eNumber, yearHired, hourlySalary, weeklySalary);
return pw;
}
}
Production Worker [
Name: Meg
ID: 524-E
Year Hired: 1988
WeeklySalary: $9470.21
Hourly Salary: $17.94,
Name: Ruth
ID: 724-H
Year Hired: 1977
WeeklySalary: $5291.17
Hourly Salary: $25.90,
Name: Stewart
ID: 902-I
Year Hired: 1990
WeeklySalary: $7361.63
Hourly Salary: $32.74,
Name: Ruth
ID: 664-E
Year Hired: 1983
WeeklySalary: $7772.68
Hourly Salary: $12.82,
Name: Courtney
ID: 906-F
Year Hired: 1992
WeeklySalary: $4951.66
Hourly Salary: $29.15,
Name: Cleveland
ID: 752-K
Year Hired: 1978
WeeklySalary: $2541.34
Hourly Salary: $48.00,
Name: Quagmire
ID: 549-C
Year Hired: 2008
WeeklySalary: $521.62
Hourly Salary: $44.33,
Name: Ryan
ID: 131-K
Year Hired: 2008
WeeklySalary: $5476.07
Hourly Salary: $25.59,
Name: Meg
ID: 238-D
Year Hired: 2011
WeeklySalary: $7042.55
Hourly Salary: $40.83,
Name: Joe
ID: 866-H
Year Hired: 1994
WeeklySalary: $1042.26
Hourly Salary: $24.26]
Shift Super Visor [
Name: William
ID: 823-H
Year Hired: 1986
WeeklySalary: $4441.36
YearlySalary: $61833.74
Goals: 10,
Name: Claire
ID: 561-K
Year Hired: 1991
WeeklySalary: $8071.05
YearlySalary: $74314.02
Goals: 31,
Name: Amelia
ID: 517-H
Year Hired: 1987
WeeklySalary: $6870.02
YearlySalary: $59114.45
Goals: 13,
Name: Noah
ID: 517-D
Year Hired: 1984
WeeklySalary: $3399.49
YearlySalary: $72129.84
Goals: 15,
Name: Isaac
ID: 459-D
Year Hired: 1982
WeeklySalary: $2445.37
YearlySalary: $72054.27
Goals: 8,
Name: Isaac
ID: 108-I
Year Hired: 2008
WeeklySalary: $1516.34
YearlySalary: $44618.78
Goals: 10,
Name: Noah
ID: 532-B
Year Hired: 2010
WeeklySalary: $4867.20
YearlySalary: $71482.40
Goals: 4,
Name: Amelia
ID: 048-M
Year Hired: 1995
WeeklySalary: $4133.30
YearlySalary: $40960.02
Goals: 29,
Name: Austin
ID: 259-G
Year Hired: 2005
WeeklySalary: $4471.34
YearlySalary: $73464.87
Goals: 6,
Name: Isaac
ID: 001-A
Year Hired: 2001
WeeklySalary: $3092.65
YearlySalary: $55253.13
Goals: 30]
Manager [
Name: Caitlyn
ID: 628-C
Year Hired: 2004
WeeklySalary: $905.46
YearlySalary: $93418.90
Department: Marketing,
Name: Mason
ID: 702-H
Year Hired: 1987
WeeklySalary: $5139.92
YearlySalary: $96679.29
Department: Research,
Name: Laine
ID: 258-H
Year Hired: 2007
WeeklySalary: $4882.15
YearlySalary: $94523.28
Department: Research,
Name: Sophia
ID: 977-D
Year Hired: 1988
WeeklySalary: $948.75
YearlySalary: $61562.96
Department: PayRoll,
Name: Liam
ID: 481-I
Year Hired: 1995
WeeklySalary: $83.83
YearlySalary: $80221.32
Department: PayRoll,
Name: Ethan
ID: 665-K
Year Hired: 2009
WeeklySalary: $700.70
YearlySalary: $115002.03
Department: Marketing,
Name: Sophia
ID: 384-M
Year Hired: 1986
WeeklySalary: $6330.35
YearlySalary: $98009.96
Department: PayRoll,
Name: Jackson
ID: 826-I
Year Hired: 1981
WeeklySalary: $5484.05
YearlySalary: $118841.85
Department: Accounting,
Name: Laine
ID: 255-H
Year Hired: 1995
WeeklySalary: $4.04
YearlySalary: $60571.28
Department: Accounting,
Name: Jackson
ID: 812-D
Year Hired: 1995
WeeklySalary: $3393.65
YearlySalary: $118430.95
Department: Accounting]
I'm not going to add to for_yan's code because it is working to the point that the program runs.
What I suggest is you integrate for_yan's code in your program. Then make the changes he suggested. If you get stuck at that point, please post your entire code as an attached file (a zip file is fine) and then ask the new question.
What I suggest is you integrate for_yan's code in your program. Then make the changes he suggested. If you get stuck at that point, please post your entire code as an attached file (a zip file is fine) and then ask the new question.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
These methods return boolean
Shift.getProductionGoals()
Shift.shiftDay()
Shift.getDay());
What was your intentsion when you were adding them to arraylists
conatinuing ProductionWorker, SuperViosr Manager elements ?
pw.add(Shift.getProduction
pw.add(Shift.shiftDay());
pw.add(Shift.getDay());
Please, explain this and we could think waht to do with it - the rest of the code seesm to complile at least