subject

An updated PriorityCustomer class is provided for you (download from Canvas). You must use that class, without alternations, for the creation of your PriorityCustomer objects. You must analyze the class and use the provided methods to achieve the desired functionality of the program. You will also need to create two additional classes. The first will be a PriorityQueue class that will represent the data structure for holding your Customer objects. In your PriorityQueue class, you will create the actual heap that will act as the priority queue. You must use an array representation of a heap. No ArrayLists or linked structures! The second class you will need to create is a driver where your store simulation will take place.

Customers with a priority value higher than other existing customers should be placed in front of them. This is simulated by utilizing a Max Heap to implement your priority queue. The only exception to this is for the customer in the front of the line (the one currently being serviced). If a new customer is added to the line with a higher priority than the front customer, the new customer should not be put in front of the customer being serviced – only those that are also waiting in line. The store simulation with regards to the service time of customers, probability that new customers show up, and program output will be the same as it was for the first program.

The program (driver) should simulate 60 minutes of activity at the store. Each iteration of your program should represent one minute. At each iteration (minute), your program should do the following:

a. Check to see if new customers are added to the queue. There is a 25% chance that new customers show up (need to be added to the queue) every minute. This does not mean you should add a customer every four iterations, but rather each iteration should have its own 25% chance.

b. Update the customer object currently being serviced (if one exists). This will be the customer object at the front of the queue. If the customer has been completely serviced, remove them from the queue.

During execution, your program should output the following information:

c. When a new customer is added to the queue, output, "New customer added! Queue length is now X" where X is the size of the queue after the new customer has been added.

d. When a customer has been completely serviced, output, "Customer serviced and removed from the queue. Quest length is now X" where X is the size of the queue after the customer has been removed.

e. At the end of each iteration (minute), output, "" to visually identify the passing of time.

When your simulation ends, your program should also output the following information:

a. Total number of customers serviced
b. Maximum line length during the simulation

NOTE YOU have to use the class I am pasting below and also you must have 2 separate classes! ( 3 in total with the one I provided). YOU CAN NOT USE JAVA'S BUILT IN CLASS.

/* class that I have to use

*/

import java. util. Random;

public class PriorityCustomer {

private int serviceTime; // ServiceTime for this Customer
private int priority; // Priority for this Customer

/// Constructor
public PriorityCustomer() {
serviceTime = new Random().nextInt(5) + 1; // Randomly assign required service time 1-5
priority = new Random().nextInt(5) + 1; // Randomly assign priority 1-5
}

public int getPriority(){
return priority;
}

/// Getter for ServiceTime
public int getServiceTime() {
return serviceTime;
}

/// Decrement ServiceTime by 1
public void decServiceTime() {
serviceTime--;
}
}

ansver
Answers: 2

Other questions on the subject: Computers and Technology

image
Computers and Technology, 21.06.2019 14:00, mpete1234567890
Var add = function( x, y ) { return ( x + y ); } alert( add (5, 3) ); 11. (refer to code example 2.) the function a. accepts 2 parameters and returns 2 values. b. accepts 2 parameters and returns 1 value. c. accepts 2 parameters and does not return a value. d. does not accept a parameter and returns 1 value.
Answers: 1
image
Computers and Technology, 21.06.2019 23:00, fluffy374747
The animal classthis class represents a an animal residing at a zoo. it has a weight (in pounds),height (in inches), a name, and a color. the methods in the class include constructors, getters, and a tostring. you will finish the implementation of these methods. referto the code documentation.1.getters: you will need to implement getter methods. these get a value (froma member variable) in the animal class. you will make a getter method toreturn each variable (weight, height, name, color). reference getname if youare having issues.2.tostring: you will need to finish the tostring method. this returns a stringcontaining information about an animal. the output string should be of theformat: ” (name) , a ( color )â’colored animal . ( weight ) pounds , ( height ) inches .\n”the height and weight are formatted to 1 decimal place. recall from lab 1how to format strings neatly using string. see the reference sectionfor more about string. format.
Answers: 2
image
Computers and Technology, 22.06.2019 13:00, cookie1701
Why the bear has a slunky tail determine the meaning of the word slunk in the story
Answers: 1
image
Computers and Technology, 23.06.2019 09:30, kreshnikolloma
You wanted to look up information about alzheimer's, but you were unsure if it was spelled "alsheimer's" or "alzheimer's." which advanced search strategy would be useful? a) a boolean search b) using a wild card in your search c) trying different search engines d) doing a search for "alsheimer's not alzheimer's" asap. ill give brainlist.
Answers: 1
You know the right answer?
An updated PriorityCustomer class is provided for you (download from Canvas). You must use that clas...

Questions in other subjects: