Requirements description

Assume you work part-time at a Cafe. As the only employee who knows java programming, you help to write an ordering application for the store.

The following is a brief requirement description with some sample output.

1. Selecting Breakfast, Lunch or Dinner

When the program starts, it first shows option Breakfast or Lunch. A sample output is as follows.

=== Select Breakfast or Lunch or Dinner: ===
1. Breakfast
2. Lunch
3. Dinner

You are supposed to validate the input.

If the user enters a letter or a number not 1 or 2 or 3, the user will see an error message.

A sample output for invalid number is as follows.

Select Breakfast or Lunch [1, 2, 3]: 0
Error! Number must be greater than 0.
Select Breakfast or Lunch [1, 2, 3]:

2. Selecting Coffee

When the program continues, it shows a list/menu of coffee and their prices, then asks a user to select a coffee by entering an integer number. A sample output is as follows.

=== Select Coffee: ===
1 Espresso $4.50
2 Latte $4.50
3 Cappuccino $6.00
4 Cold Brew $4.00
5 Quit Coffee selection
Select a coffee [1, 5]:

You are supposed to validate the input.

If the user enters a letter or a number not between 1 and 5, the user will see an error message.

A sample output for invalid number is as follows.

Select a coffee [1, 5]: 0
Error! Number must be greater than 0.
Select a coffee [1, 5]:

In your program, you can hard-code the information for coffee (i.e., coffee names and prices) shown above, such as "1 Espresso $4.50" and use the hard-code price, such as 4.50, for calculation of a total price of the order.

After the user makes a choice for coffee, such as 2 for Latte. The program continues asking for selecting a coffee so that the user can have multiple coffee orders. The user can enter "5" to quit coffee selection. A sample output is as follows.

=== Select Coffee: ===
1 Espresso $4.50
2 Latte $4.50
3 Cappuccino $6.00
4 Cold Brew $4.00
5 Quit Coffee selection
Select Coffee: [1, 5]: 2
=== Select Coffee: ===
1 Espresso $4.50
2 Latte $4.50
3 Cappuccino $6.00
4 Cold Brew $4.00
5 Quit Coffee selection
Select Coffee: [1, 5]: 5

3. Selecting Food

After Coffee selection, the program shows food selection. A sample output is as follows.

=== Select Food: ===
1 Tuna Sandwich $10.00
2 Chicken Sandwich $10.00
3 Burrito $12.00
4 Yogurt Bowl $9.00
5 Avocado Toast $9.00
6 Quit Food selection
Select Food: [1, 6]: 1

Input validation is needed and works as before. Like Coffee selection which allows selecting multiple Coffee orders, food selection also repeats after the user enters a valid number between 1 and 5.

You hard-code the information for food shown above, such as "1 Tuna Sandwich $10.00" and use the hard-code price, such as 10.00, for calculation of the total price of the order.

4. Entering a customer's name and phone number

After making a Food selection, the program asks for the user's name so that the user can enter text like John or John Smith.

=== Select Food: ===
1 Tuna Sandwich $10.00
2 Chicken Sandwich $10.00
3 Burrito $12.00
4 Yogurt Bowl $9.00
5 Avocado Toast $9.00
6 Quit Food selection

Select Food: [1, 6]: 6

Enter customer's name: John Smith

Enter customer’s phone number: 626-111-2222

5. Displaying and writing order line information

After entering a name, the program prints details for this order line in computer monitor. The information includes the six fields: meal type(breakfast or lunch or dinner), customer name, coffee(quantity), food(quantity), and a (formatted) total price, and each field is separated by a comma and a space. A sample output to the monitor is as follows.

Enter customer's name: John Smith
Enter customer’s phone number: 626-111-2222

Lunch, name: John Smith, phone: 626-111-2222
Espresso(2), Burrito(1), $21.00

Besides showing on monitor, the same order line content is written (appended) to a text file named orderdate.txt and each order line occupies two lines in the text file. Here is a specific example for an order in the orderdate.txt.

Lunch, name: John Smith, phone: 626-111-2222
Espresso(2), Burrito(1), $21.00

Your program needs to create the output file, named orderdate.txt, if it doesn't exist yet, and later appends (not overwrite) order line information to the file. So next time when your program is executed, new order information will be appended to the orderdate.txt file. You must use a relative path when creating an output stream writer object. For simplicity, we dont record any information about the sales clerk and one order includes only one coffee.

Design requirements

You must have at least the following java classes. You may have additional classes if you want.

[1] a CafeOrder class to simulate the CafeOrder entity in real world, which has fields of meal type, coffee, food, and price of the order, customer name, and corresponding methods. This class also provides a method to append the content of an order's content to the output text file, orderdate.txt. (CafeOrder.java)

[2] a java application, named CafeApp.java, that contains a main method. This class interacts with CafeOrder class.

Academic Honesty!
It is not our intention to break the school's academic policy. Posted solutions are meant to be used as a reference and should not be submitted as is. We are not held liable for any misuse of the solutions. Please see the frequently asked questions page for further questions and inquiries.
Kindly complete the form. Please provide a valid email address and we will get back to you within 24 hours. Payment is through PayPal, Buy me a Coffee or Cryptocurrency. We are a nonprofit organization however we need funds to keep this organization operating and to be able to complete our research and development projects.