CUS 1126 Intro to Data Structures – Exam 2 (take home)
Instructions: For the program below, upload the project (in your eclipse-workspace folder) as a zip file.
Implementing a priority queue to manage customers
In this program, we will implement a priority queue to manage customers of a business. Note that we are not using the built-in PriorityQueue class, rather we are building our own priority queue of Customer objects. Each customer has a priority number (indicating the order in which they will be served, with the smaller values being served first).
Implement a class called Customer that includes an int priority, a String name, and a reference to the next Customer in the queue. The Customers will be ordered by priority in the queue. Implement another class called CustomerPriorityQueue that contains a reference to the first Customer in the queue, a constructor to initialize that reference to null, along with the following methods:
public void addCustomer(Customer c): Adds a Customer object to the queue in the correct position, ordered by priority
public Customer removeCustomer(): Removes and returns the first Customer in the queue.
isEmpty(): A boolean method that returns true if the queue is empty, false otherwise.
Then, create a class called ManageCustomers in which we will have a main method. Here, we will create a CustomerPriorityQueue of customers called customerQueue. Create a menu to allow a user to manage a customer queue with the following options (note that the menu should repeat until the user selects option 4 – Exit):
Manage your customers with the following options: 1 – Add new customer 2 – Process customer with highest priority 3 – Process all customers in order of priority 4 - Exit
The options will do the following:
1 – Add new customer: Obtain user input for the customer’s priority and name, create new Customer object, and add to queue.
2 – Process customer with highest priority: Remove first customer and display the priority and name of customer being processed.
3 – Process all customers in order of priority: Remove all customers and display the priority and name of the customers.
21 freelancer chào giá trung bình$31 cho công việc này
Hi, We are a team of experienced Java developers with expertise in Algorithms and Data Structures. We are known for delivng projects in time, with correctness and accuracy. Please feel free to drop a message.
"HI sir, i'm interested to work no your project, we were seen your post and requirement and we can complete your project with our great responsibility and provide you a good quality and error free project.