Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

can comeone help me complete this class? // DO NOT ADD NEW METHODS OR NEW DATA F

ID: 656473 • Letter: C

Question

can comeone help me complete this class?

// DO NOT ADD NEW METHODS OR NEW DATA FIELDS!

package PJ3;

class Cashier {

// cashier id and current customer which is served by this cashier
private int cashierID;
private Customer serveCustomer;

// start time and end time of current (free or busy) interval
private int startClockTime;
private int endClockTime;

// for keeping statistical data
private int totalFreeTime;
private int totalBusyTime;
private int totalCustomers;

// Constructor
Cashier()
{
   // add statements
}


// Constructor with cashier id
Cashier(int cashierId)
{
   // add statements
   totalCustomers = 0;
}

// accessor methods

int getCashierID()
{
   return cashierID;
}

Customer getCurrentCustomer()
{
   // add statements
   return null;
}

// Transition from free interval to busy interval
void freeToBusy (Customer serveCustomer, int currentTime)
{
   // goal : switch from free interval to busy interval
   // i.e. end free interval, start busy interval
// to serve a new customer
//
   // steps : update totalFreeTime
   //    set startClockTime, endClockTime, serveCustomer,
   //    update totalCustomers

   // add statements
}

// Transition from busy interval to free interval
Customer busyToFree ()
{
   // goal : switch from busy interval to free interval
   // i.e. end busy interval to return served customer,
// start free interval
    //
   // steps : update totalBusyTime
   //    set startClockTime
   // return serveCustomer

   // add statements
   return null;
}

// Return end busy clock time, use in priority queue
int getEndBusyClockTime()
{
   // add statements
   return 0;
}

// For free interval at the end of simulation,
// update totalFreeTime
void setEndFreeClockTime (int endsimulationtime)
{
   // for free interval at the end of simulation:
   // set endClockTime, update totalFreeTime

   // add statements
}

// For busy interval at the end of simulation,
// update totalBusyTime
void setEndBusyClockTime (int endsimulationtime)
{
   // for busy interval at the end of simulation:
   // set endClockTime, update totalBusyTime

   // add statements
}

// functions for printing statistics :
void printStatistics ()
{
   // print cashier statistics, see project statement

   System.out.println(" Cashier ID : "+cashierID);
   System.out.println(" Total free time : "+totalFreeTime);
   System.out.println(" Total busy time : "+totalBusyTime);
   System.out.println(" Total # of customers : "+totalCustomers);
   if (totalCustomers > 0)
   System.out.format(" Average checkout time : %.2f%n ",(totalBusyTime*1.0)/totalCustomers);
}

public String toString()
{
   return "CashierID="+cashierID+":startClockTime="+startClockTime+
":endClockTime="+endClockTime+">>serveCustomer:"+serveCustomer;
}

public static void main(String[] args) {
// quick check
Customer mycustomer = new Customer(1,15,5);
   Cashier mycashier = new Cashier(5);
mycashier.freeToBusy (mycustomer, 12);
System.out.println(mycashier);

}

};

Explanation / Answer

class Cashier {

// cashier id and current customer which is served by this cashier
private int cashierID;
private Customer serveCustomer;

// start time and end time of current (free or busy) interval
private int startClockTime;
private int endClockTime;

// for keeping statistical data
private int totalFreeTime;
private int totalBusyTime;
private int totalCustomers;

// Constructor
Cashier()
{
   cashierID=0;
  
   startClockTime=0;
    endClockTime=0;

    totalFreeTime=0;
    totalBusyTime=0;
    totalCustomers=0;
}


// Constructor with cashier id
Cashier(int cashierId)
{
   cashierID=cashierId;
totalCustomers = 0;
}

// accessor methods

int getCashierID()
{
return cashierID;
}

Customer getCurrentCustomer()
{
return serveCustomer;
  
}

// Transition from free interval to busy interval
void freeToBusy (Customer serveCustomer, int currentTime)
{
// goal : switch from free interval to busy interval
// i.e. end free interval, start busy interval
// to serve a new customer
//
// steps : update totalFreeTime
// set startClockTime, endClockTime, serveCustomer,
// update totalCustomers

// add statements
}

// Transition from busy interval to free interval
Customer busyToFree ()
{
// goal : switch from busy interval to free interval
// i.e. end busy interval to return served customer,
// start free interval
//
// steps : update totalBusyTime
// set startClockTime
// return serveCustomer

// add statements
return null;
}

// Return end busy clock time, use in priority queue
int getEndBusyClockTime()
{
// add statements
return 0;
}

// For free interval at the end of simulation,
// update totalFreeTime
void setEndFreeClockTime (int endsimulationtime)
{
// for free interval at the end of simulation:
// set endClockTime, update totalFreeTime

// add statements
}

// For busy interval at the end of simulation,
// update totalBusyTime
void setEndBusyClockTime (int endsimulationtime)
{
// for busy interval at the end of simulation:
// set endClockTime, update totalBusyTime

// add statements
}

// functions for printing statistics :
void printStatistics ()
{
// print cashier statistics, see project statement

System.out.println(" Cashier ID : "+cashierID);
System.out.println(" Total free time : "+totalFreeTime);
System.out.println(" Total busy time : "+totalBusyTime);
System.out.println(" Total # of customers : "+totalCustomers);
if (totalCustomers > 0)
System.out.format(" Average checkout time : %.2f%n ",(totalBusyTime*1.0)/totalCustomers);
}

public String toString()
{
return "CashierID="+cashierID+":startClockTime="+startClockTime+
":endClockTime="+endClockTime+">>serveCustomer:"+serveCustomer;
}

public static void main(String[] args) {
// quick check
Customer mycustomer = new Customer(1,15,5);
Cashier mycashier = new Cashier(5);
mycashier.freeToBusy (mycustomer, 12);
System.out.println(mycashier);

}

};

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Chat Now And Get Quote