Menu

[Solved]6 Objectives Assignment Enhance Knowledge Skill Java Gain Understanding Experience Queues Q37204249

6. The objectives of this assignment are to:

  1. Further enhance your knowledge and skill in Java.
  2. Gain an understanding and experience with queues.
  3. Gain an understanding and experience with discrete eventsimulation.
  4. Further enhance your understanding and experience usinggenerics.
  5. Continue to practice good programming techniques.

Create a queue class named MyQueue that stores generics with thefollowing methods below. Write a test program that thoroughly testsyour queue implementation.

void enqueue(E item)

add item to rear of queue

E peek()

return item at front of queue, but leave it in queue

E dequeue()

return item from front of queue and remove it from queue

int size()

returns number of elements in queue

boolean isEmpty()

returns whether or not queue is empty

Once the queue is working, create a class Simulation thatperforms a discrete event simulation for an ice cream store asdescribed below. The class will require the following functions tobe implemented:

Simulation(int num)

constructor that initializes the simulation and creates an eventqueue containing num customers

void run()

runs the simulation and prints the arrivals and departures

void stats()

prints a report of the desired statistics

optional – DO NOT attempt until simulation is working; thiswill not influence your grade

Write a client program named Prog6 that performs a discreteevent simulation which simulates the business transactions thatoccur at an ice cream store. Assume the following:

  1. The ice cream store always has one employee available to helpcustomers.
  2. Customers arrive and wait in line until the employee isavailable.
  3. Your simulation will initially create a list of ncustomers (where n is specified in the constructor) thatarrive at various times on the simulation clock where each customerarrives between 0 and 3 minutes of time later than the previouscustomer. The time intervals 0 through 3 are all generated in anequiprobable manner. Each customer object is placed in the arrivalqueue for use during the simulation.
  4. Customer transactions always involve purchasing a single icecream cone. The time that is takes to complete a customertransaction is 2 minutes.
  5. If a customer arrives when the employee is busy, then thatcustomer is placed on a queue of waiting customers.
  6. Each time a customer arrives at the ice cream store, thesimulation should print the identification number of the customerand the time on the simulation clock that the customer arrived. Theidentification number of a customer is their order of arrival atthe ice cream store. The first customer has ID = 1, the secondcustomer has ID = 2, etc.
  7. Each time a transaction is completed with a customer, thesimulation should print the identification number of the customerand the time on the simulation clock that the transaction wascompleted.
  8. Each time a customer departs, the queue of waiting customersmust be checked. If there are customers waiting, the first customeron the wait queue will be removed from the queue and serviced.

Two queues are required for thesimulation: the arrival queue and the wait queue.

Challenge

For those looking for a more challenging assignment, implementthe stats() method in the Simulation class to print statistics,such as the average/max time spent in the wait queue and theaverage/max number or customers in the wait queue. ONLY TRY THISAFTER EVERYTHING ELSE IS WORKING.

Requirements

  • Your source code should use proper object-oriented style. Thatis, the main program should only instantiate a class which displaysand processes the menu.
  • Your source code should be documented using Javadoc styleaccording to the course standards.
  • Follow good programming practices.
  • Use the default package in your project; do not specify apackage in your code.
  • Your test program must be named Prog6.

Expert Answer


Answer to 6. The objectives of this assignment are to: Further enhance your knowledge and skill in Java. Gain an understanding and… . . .

OR


Leave a Reply

Your email address will not be published. Required fields are marked *