Question: Code in Java Summary of problem: This program models a supermarket. There are two types of shoppers - fast shoppers and big shoppers. They are

Code in Java

Code in Java Summary of problem: This program models a supermarket. There

are two types of shoppers - fast shoppers and big shoppers. They

are all mixed together when shopping, but go onto different lines when

checking out. Checking out requires waiting online, and then actually being checked

out, once the clerk is available. After either type of shoppers is

checked out that shopper is put into a separate list of those

who are done shopping. interface ShoppingTimeRemaining (5 points) Has two abstract methods

setShoppingTimeRemaining accepts an int value and a void return getShoppingTimeRemaining has no

parameters and returns an int class Shopper (15 points) implements ShoppingTimeRemaining This

Summary of problem: This program models a supermarket. There are two types of shoppers - fast shoppers and big shoppers. They are all mixed together when shopping, but go onto different lines when checking out. Checking out requires waiting online, and then actually being checked out, once the clerk is available. After either type of shoppers is checked out that shopper is put into a separate list of those who are done shopping. interface ShoppingTimeRemaining (5 points) Has two abstract methods setShoppingTimeRemaining accepts an int value and a void return getShoppingTimeRemaining has no parameters and returns an int class Shopper (15 points) implements ShoppingTimeRemaining This is an abstract class. It has one instance variable shopperType of type String. It has a default constructor that calls the setShopperType method with an empty String It has a second constructor with a String parameter referring to the shopperType, that calls the setShopperType method with the parameter's value It has both mutator and accessor methods for shopperType. It has four public abstract methods: setTimeIntoCheckoutLine accepts an int value and a void return getTotalTimeCheckingOut has no parameters and returns an int class FastShopper is a subclass of Shopper (20 points) - note: all the abstract methods in Shopper and in the interface ShoppingTimeRemaing are implemented here Note: You don'trl say implement in the class header since you this is done in Shopper It has a public static int variable fastShopperCounter set to 0 It has a public static int variable TIMEWITHCHECKER =1 It has a private String instance variable fastShopperID - note: has a simple accessor method It has the following additional private instance int variables, each of which has a simple accesso method that returns its current value. Those with an * also have a simple mutator method - startTime* - timeShopping - shoppingTimeRemaining* - timeIntoCheckoutLine* - timeOutOfCheckoutLine - endTime - calculated in calculateFinalDurations method - totalTimeCheckingOut - calculated in calculateFinalDurations method - totalTimeInStore - calculated in calculateFinalDurations method It also has a Random reference variable randy (don't forget the proper import statement) There is one constructor with one int input for the startTime;. - It calls the super constructor with the String "FastShopper" - It creates a Random object that randy refers to using as the seed the fastShopperCounter - It calls setFastShopperID ) with no parameters - It calls setStartTime with the startTime as the parameter - It calls setTimeShopping with no parameters - It calls setShoppingTimeRemaining with the timeShopping (Must be done last) The following methods has special code used in the mutator method. setFastShopperID has no parameters and a void return. It increments fastShopperCounter by 1 sets fastShopperID equal to the concatenation of the return from getShopperType() and fastShopperCounter setTimeShopping has no parameters and a void return It sets the timeShopping variable to a value between 1 and 6 inclusively using the randy Random object setTimeOutOfCheckoutLine has an int input parameter and a void return It sets timeOutOfCheckoutLine to the input parameter value It calls calculateFinalDurations with no parameters There are two additional methods. calculateFinalDurations has no parameters and a void return and sets the following values: endTime equals the sum of timeOutOfCheckoutLine and TIMEWITHCHECKER totalTimeCheckingOut is the positive difference of the endTime and timeIntoCheckoutLine totalTimeInStore is the positive difference between the endTime and the startTime; There is also a toString method that returns a formatted String for printing as shown in the output. It includes the following values: fastShopperID, startTime, endTime, timeShopping, totalTimeCheckingOut, totalTimeInStore class BigShopper is a subclass of Shopper (20 points) - note: all the abstract methods in Shopper and in the interface ShoppingTimeRemaing are implemented here Note: You don'trl say implement in the class header since you this is done in Shopper Note: Items in red are different From FastShopper It has a public static int variable bigShopperCounter set to 0 It has a public static int variable TIMEWITHCHECKER =2 It has a private String instance variable bigShopperID - - note: has a simple accessor method It has the following additional private instance int variables, each of which has a simple accessor method that returns its current value. Those with an also have a simple mutator method - startTime* - timeShopping - shoppingTimeRemaining* - timeIntoCheckoutLine* - timeOutOfCheckoutLine - endTime - calculated in calculateFinalDurations method - totalTimeCheckingOut - calculated in calculateFinalDurations method - totalTimeInStore - calculated in calculateFinalDurations method It also has a Random reference variable randy (don't forget the proper import statement) There is one constructor with one int input for the startTime. - It calls the super constructor with the String "BigShopper" - It creates a Random object that randy refer to using as the seed the bigShopperCounter - It calls setBigShopperID0 with no parameters - It calls setStartTime with the startTime as the parameter - It calls setTimeShopping with no parameters - It calls setShoppingTimeRemaining with the timeShopping (Must be done last) The following methods has special code used in the mutator method. setBigShopperID has no parameters and a void return. It increments bigShopperCounter by 1 sets bigShopperID equal to the concatenation of the return from getShopperType() and bigShopperCounter setTimeShopping has no parameters and a void return It sets the timeShopping variable to a value between 5 and 15 inclusively using the randy Random object setTimeOutOfCheckoutLine has an int input parameter and a void return It sets timeOutOfCheckoutLine to the input parameter value It calls calculateFinalDurations with no parameters There are two additional methods. calculateFinalDurations has no parameters and a void return and sets the following values: endTime equals the sum of timeOutOfCheckoutLine and TIMEWITHCHECKER totalTimeCheckingOut is the positive difference of the endTime and timeIntoCheckoutLine totalTimeInStore is the positive difference between the endTime and the startTime; There is also a toString method that returns a formatted String for printing as shown in the output. It includes the following values: bigShopperID, startTime, endTime, timeShopping, totalTimeCheckingOut, totalTimeInStore Method operateSupermarket with an int parameter with the minutes to run the simulation and a void return Set an int minCounter with the current minute equal to 1 While (currentShoppers is not empty or bigCheckQut is not empty or fastCheckout is not empty //This section lets more shoppers in If the minCounter

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!