Assignment: Write a series of java classes with methods that manages a loyalty p
ID: 3581929 • Letter: A
Question
Assignment: Write a series of java classes with methods that manages a loyalty points/reward program and employment for a small bakery. 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
For the loyalty rewards class:
-Spending a certain amount of money will earn the customer a certain amount of points that the customer can use.
-Loyalty Card Check - this method will determine if a customer is a member of the Loyalty Program
-Loyalty Card Add - this method will add to the customer points if the customer is a member of the loyalty program
-Loyalty Discount - this method will apply the discount to the
And/Or
-A punch card system where a customer buys 9 coffees and gets one free
For the employee class(es):
-Add new employee and personal info
-Time Card Check – this method will check to see if the employee worked any hours this week
Time Card Add – this method will add hours to the employees time card.
Time Card Total – this method will return the total hours worked by an employee.
Employee Shift – this method will assign employees to a number of shifts.
Empty Shifts – this method will determine if any shift is empty.
-Shift Add – This will add an employee to a shift.
-Shift Min – this method will set the minimum number of workers needed for a shift
thank you so much!!!:)
Explanation / Answer
Employee classes
-----------------------------
class Employee
{
int age;
private int shift;
String name, address, gender;
Scanner get = new Scanner(System.in);
Employee()
{
System.out.println("Enter Name of the Employee:");
name = get.nextLine();
System.out.println("Enter Gender of the Employee:");
gender = get.nextLine();
System.out.println("Enter Address of the Employee:");
address = get.nextLine();
System.out.println("Enter Age:");
age = get.nextInt();
id = rand();
}
public bool check_time( String id)
{
if(this.hours>0)
return true; //employee has worked this week
return false; //employee has not worked this week
}
public void add_time( String id, double hours)
{
this.hours = this.hours + hours;
}
public void add_shift(String id , int shift_num)
{
/* maintain a global shift_num variable indicating the number of avaible shifts */
if(shifft_num <= 0) //no shifts are avaiblee to assign
return;
this.shift = this.shift + 1; //employer is given a shift
}
void display()
{
System.out.println("Employee Name: "+name);
System.out.println("Age: "+age);
System.out.println("Gender: "+gender);
System.out.println("Address: "+address);
}
}
class Employees
{
public static void main(String args[])
{
Employee ob1 = new Employee();
ob1.add_new();
}
}
-------------------------------
make a shift class holding the min number of employers for that particular shift instance and shift_employee maitaing the number of employees currently assigned to that shift
class Shift
{
private String shift_id;
private int min_shifts;
public int shift_employee;
public void add_shift()
{
id = getnextLine();
min_shifts = getnextLine();
shift_employee = getnextLine();
}
}
use the add shift method to assign values to it from driver main function
examplee
ob = new Shift;
ob.add_shift();
now simple methods can be written to this class to add an employee to a shift ( add the shift to the employee from previously defined method and increment that shift's shift_employee)
Shift min method is not explicitly required since we're already initializing it during instance creation.
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.