You've been hired by Biggy’s Popcorn to write a Java console application that
handles popcorn orders at their store. The application has the following two
classes:
Order.java
This class represents a customer in line who wants to buy popcorn and includes:
static total order amount – count of all popcorn bags sold.
order amount – the number of popcorn bags the customer wants.
next – a pointer to the next Order in the queue.
A constructor with no parameters that set the fields, respectively, to these
values:
order amount = -1
next = null
these values:
total order amount = total order amount + orderAmount
order amount – set from parameter
next – set from parameter
static).
total order amount static).
HW7.java
This class contains the main method and maintains a queue of Orders. Create text
file Events.txt, paste the following data into it, and place the file in your project
folder. It has the following columns:
1) Event type – this will be either:
CQ means a customer entered the back of the line.
CH means the order was handled for the customer at the front of the
line.
2) Order amount – the number of popcorn bags the customer wants.
Events.txt
CQ 4
CQ 3
CH 0
CQ 7
CH 0
CQ 5
CQ 2
CQ 8
CH 0
CM 6
CH 0
CQ 4
CH 0
CH 0
CH 0
Read the data from file Events.txt. For each event, print an event number, event
type, amount ordered, line length (number of customers in line), and the result of
the processed event. Represent the customers in line with a queue (yes, the data
structure). Use a linked list, not an array or array list. Create the following
methods:
Get Free Quote!
278 Experts Online