1 – Project 3 Changelog • Typos fixed: o QueueSystem instead of QueueingSystem. o Default values of some attributes. o Parameter types for Client and VIPClient. o Some other...

1 answer below »
Please make sure to read instructions. Simple java code- just a lot of typing- no imports allowed


1 – Project 3 Changelog • Typos fixed: o QueueSystem instead of QueueingSystem. o Default values of some attributes. o Parameter types for Client and VIPClient. o Some other typos fixed / Additional clarification added. o clientsInQueue attribute in class Queue was missing. Description Let's assume we're developing a queueing policy evaluation tool for a company facing high demand. You will implement a program that can simulate and evaluate the performance of a given queueing policy. There is no template provided for this exercise, so make sure that you read the instructions carefully to determine how your code should be structured. You will be making ten classes in their respective .java files. Make sure to include all the fields and methods asked for, paying particular attention to the access modifiers, return types, capitalization, and parameter order and type. Overview 1. Create the Java classes Prioritizable, Client, VIPClient, Request, InformationRequest, ReturningItems, BuyingProducts, QueueSystem, Queue, VIPQueue. You will also need to write the Enums Gender and Status. 2. Include all the fields and methods described below. 3. Test your code for correctness. 4. Prepare the assignment for submission and submit the java files through Gradescope. Rules 1. You may not import any extra functionality besides the default. For example, System and Math are imported by default and thus may be used, whereas something like ArrayList must be explicitly imported so it is disallowed. 2. The main method will not be tested; you may use it any way you want. 3. Comment your code, especially the parts where it is not obvious what you're doing. 2 Instructions 1. Implement the java classes described below in distinct, appropriately named, .java files. 2. You must do your own testing. Feel free to edit the main method in the driver class to test your code. 3. Submit the files on Gradescope. Make sure that you submit the correct files. 4. For all the private fields define getters and setters following this signature: a. The getter for a field declared as private String someField will be: public String getSomeField() b. The setter for a field declared as private String someField will be: public void setSomeField(String someField) 5. Feel free to add additional methods or attributes to the classes. The additional fields must be private. The Prioritizable interface: This interface will be implemented by classes that represent objects to which we can assign a priority value. In this assignment, the Request and VIPClient classes will implement this interface. Any classes implementing Prioritizable will have the implementation of these methods: - public void setPriority(int a); - public int getPriority(); The Client class: This class represents a client who arrives at a specific time in the system. If no server is available, the client joins the waitingLine before joining the first available queue. If the waitingLine is full, the client leaves without being served. See more detailed information about this flow on page 10. You need to implement constructors and methods to instantiate the fields of a Client. ➔ Fields: ◆ id: an int that uniquely identifies the client. ◆ firstName: a String that represents the first name of the client. ◆ lastName: a String that represents the last name of the client. ◆ yearOfBirth: an int that represents the year of birth of the client. ◆ gender: an Enum type, Gender, that represents the gender of the client: MALE or FEMALE. 3 ◆ requests: an array of Requests that the client wants to assign to a server. ◆ arrivalTime: an int indicating the arrival time of the client in the system. ◆ waitingTime: an int indicating for how long the client has been in the waiting line before joining a server queue / or before leaving without being served. ◆ timeInQueue: an int indicating how long the client is in a server queue. ◆ serviceTime: an int indicating how long the server takes to process the jobs. ◆ departureTime: an int indicating at what time the client leaved the system (after being served or left without being served) ◆ patience: an int indicating how long the client can stay before leaving the system if not being served. All fields are private. Feel free to add your own attributes, they must be private. ➔ Getters and Setters. ➔ Constructors: Create three constructors for this class. See the signature of the constructors below: public Client (String firstName, String lastName, int yearOfBirth, String gender, int arrivalTime, int patience, Request[] requests) This constructor will initialize all the fields of the object Client. For the fields not provided, they will be initialized as follow: - id: autoincrement from the last id used. The first client will have id=1, the second will have id=2, etc. - waitingTime: 0 - timeInQueue: 0 - serviceTime: 0 - departureTime: 0 (default value) NB- arrivalTime: If a negative value or zero is provided, use the time indicated by the clock of the QueueSystem. public Client (String firstName, String lastName, int yearOfBirth, String gender, int patience, Request[] requests) This constructor will initialize all the fields of the object Client. For the fields that are not present in the list of parameters, they will be initialized as follow: - id: autoincrement from the last id used. The first client will have id=1, the second will have id=2, etc. - arrivalTime: The time indicated by the clock of the QueueSystem. 4 - waitingTime: 0 - timeInQueue: 0 - serviceTime: 0 - departureTime: 0 public Client (String firstName, String lastName, int yearOfBirth, String gender, int patience) This constructor will initialize all the fields of the object Client. For the fields that are not present in the list of parameters, they will be initialized as follow: - id: autoincrement from the last id used. The first client will have id=1, the second will have id=2, etc. - arrivalTime: an int indicating the arrival time of the client. If not provided, use the time indicated by the clock of the QueueSystem. - waitingTime: 0 - timeInQueue: 0 - serviceTime: 0 - departureTime: -1 (default value) Business rules: Regardless of the method used, the object state needs to be consistent and have valid values at all times. The validation and business rules are the following: - arrivalTime cannot be negative number and must be greater or equal to 1. - departureTime is either 0 (default value) or needs to be greater than or equal to arrivalTime + waitingTime + timeInQueue. We would observe departureTime = arrivalTime + waitingTime + timeInQueue only if the client left without being served. - The patience value of a client might increase based on the availability of a tv and/or coffee maker in the QueueSystem; - The client will exit the system if his time in the waitingLine and a server queue exceeds his patience value. - waitingTime cannot be a negative number. - timeInQueue cannot be a negative number. ➔ Other methods: You need to define the following methods: - public int serviceTime(): returns the time a server takes to process the requests of the client. 5 - public int estimateServiceLevel(): estimates the level of service: a number from 0 to 10. If the client is still in the system, return -1. Otherwise, deduce 1 point from the maximum value for each of these situations: - Waiting time > 4 - Waiting time > 6 - Waiting time > 8 - Waiting time > 10 - Waiting time > 12 - Time In Queue > 4 - Time In Queue > 6 - Time In Queue > 8 - Time in Queue > 10 - Time in Queue > 12 For instance: If the client had to wait 7s in the waitingLine and stayed 10s in the Queue before being served, the service level is 5. - public String toString(): This method can be called to return the object in a human-friendly manner. It returns the following information: Client: , ** Arrival Time : 0 ** Waiting Time : 5 ** Time In Queue : 2 ** Service Time : 2 ** Departure Time : 9 ** Served By Server: B ** Service Level : 9 The VIPClient class: This class represents a Client who is a VIPClient. This class implements Prioritizable. If there is no VIPQueue, this client behaves like any other client. Otherwise, the VIPClient may decide to join the VIP queue if necessary (while the other clients cannot except in some exceptionnal situation described later in this document). You need to implement constructors and methods to instantiate the fields of a VIPClient. ➔ Fields: ◆ memberSince: an int indicating the year since this client is a VIPClient; ◆ priority: an int indicating the level of priority of this client. ➔ Getters and Setters. 6 ➔ Constructors: Create a constructor for this class. See the signature of the constructors below: public VIPClient (String firstName, String lastName, int birthYear, String gender, int arrivalTime, int patience, Request[] requests, int memberSince, int priority) ➔ Other methods: You need to define the following methods: - public String toString(): This method can be called to return the object in a human-friendly manner. It returns the following information: Client: , ** Arrival Time : 0 ** Waiting Time : 5 ** Time In Queue : 2 ** Service Time : 2 ** Departure Time : 9 ** Served By Server: B ** Service Level : 9 ** VIP since : 2002 ** priority : 3 The Request abstract class: This is an abstract class representing the attributes and the behaviors that any specific requests should implement. It must implement the interface Prioritizable. ➔ Fields: ◆ description: a String describing the request; ◆ priority: an int indicating the priority of a request; ◆ difficulty: an int indicating the difficulty of the request; ◆ factor: an int indicating the factor by which the difficulty is related to the processing time of the request. ◆ startTime: an int indicating the processing start time of the request. ◆ endTime: an int indicating the processing end time of the request. ◆ completionLevel: an int indicating the completion level of the request; ◆ status: an Enum Status indicating if the state of the request: NEW, IN_PROGRESS, PROCESSED All fields are private. 7 ➔ Getters and Setters. ➔ Abstract methods: public int calculateProcessingTime () NB The time required to process a request depends on the difficulty level of this request and on the type of request. Compute this time using the following formula: - Information request: Processing time = Request difficulty x factor x numberOfQuestions - Returning item: Processing time = Request difficulty x factor x numberOfItems - Buying product: Processing time = Request difficulty x factor x numberOfItems The InformationRequest class: This class extends Request and represents a request for information. ➔ Fields: ◆ questions: an array of String representing the list of questions. ➔ Getters and Setters. ➔ Constructors: Create a constructor for this class. See the signature of the constructors below: - public InformationRequest (String description, int priority, int difficulty, String[] questions) Use those values for the attributes not mentioned in the parameter list: - factor: 1 - status: NEW - all other fields has the default value; The ReturningItems class: This class extends Request and represents a request about returning some items. ➔ Fields: ◆ itemsToReturn: an array of String representing the list of items to return
Answered 6 days AfterMar 25, 2023

Answer To: 1 – Project 3 Changelog • Typos fixed: o QueueSystem instead of QueueingSystem....

Aditi answered on Mar 31 2023
36 Votes
SOLUTION.PDF

Answer To This Question Is Available To Download

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here