Project 4: Menu Items

Academic Integrity

Academic integrity means that you submit for a grade work that is entirely yours. The following figures indicate where and who can help:

Objectives:

Assignment

For this project, you get to design and write a Java program to keep track of various menu items. Your program will store, display and modify salads, sandwiches and (you guessed it) frozen yogurts. Present the user with the following menu options:

Actions:
1) Add a salad
2) Add a sandwich
3) Add a frozen yogurt
4) Display an item
5) Display all items
6) Add a topping to an item
9) Quit
If the user does not enter one of these options, then display:
Sorry, <NUMBER> is not a valid option.
Where <NUMBER> is the user's input.

All menu items have the following:

In addition to everything that a menu item has, a main dish (salad or sandwich) also has: A salad also has: A sandwich also has: In additional to everything that a menu item has, a frozen yogurt also has: To display or add a topping to a menu item, have the user just request the name of the item. For this project, you can assume that all input will be of the right type. This means that whole numbers will be entered for menu actions, real numbers for prices and strings for everything else. For example, the user may request a menu item that does not exist or a menu action that does not exist. If the requested menu item is not in the list, then display:
Sorry, could not find <NAME> in the list
Where <NAME> is the user's input. When displaying all of the menu items, display them in the order that they were entered. Note, for adding a topping to a menu item, verify that that the specified item is in the list before requesting the topping.

For this project, you get to have at least a separate class for a salad, sandwich and frozen yogurt. Store each class in a separate file. Furthermore, they need to be organized into an inheritance hierarchy. You are welcome to have more classes if they make sense in the hierarchy. You can use an abstract class if you want to. Note, this project was designed to minimize changes to the code that was in your FrozenYogurt class from Project 3. You will need to submit each of these .java files to codePost and CougarVIEW so that they can be compiled with your other code.

Additionally, have a driver class named Menu. Store all of the menu item objects (i.e., the salad, sandwich and frozen yogurt objects) in a single ArrayList in this class. Create the ArrayList in the main() method of your Menu class. You are not allowed to explicitly use the Object class anywhere in your Menu class (meaning, you should not have "Object" anywhere in your code in Menu.java). Also, do not store String objects in the ArrayList. Lastly, do not use instanceof in any of your .java files.

Only ask for input in your Menu class. Only display output in your Menu class.

codePost does not support the package statement. If your IDE inserted, then please remove that line of code from each class.

Examples

Note, user input is in bold face blue and underlined text is required for test cases.

Add 2 Yogurts

Welcome - PUT AN ORIGINAL WELCOME MESSAGE HERE

Actions:
1) Add a salad
2) Add a sandwich
3) Add a frozen yogurt
4) Display an item
5) Display all items
6) Add a topping to an item
9) Quit

Please choose from the above actions: 3
You entered: 3
Please enter the name of the frozen yogurt: Berry Delight
You entered: Berry Delight
Please enter the price for the Berry Delight: 4.5
You entered: 4.5
Please enter the base yogurt flavor for Berry Delight: vanilla
You entered: vanilla
Please enter the topping to add to Berry Delight: blueberries
You entered: blueberries
Would you like to add another topping to Berry Delight (yes/no)? yes
You entered yes
Please enter the additional topping flavor: blackberries
You entered: blackberries
Would you like to add another topping to Berry Delight (yes/no)? yes
You entered yes
Please enter the additional topping flavor: strawberries
You entered: strawberries
Would you like to add another topping to Berry Delight (yes/no)? no
You entered no

Actions:
1) Add a salad
2) Add a sandwich
3) Add a frozen yogurt
4) Display an item
5) Display all items
6) Add a topping to an item
9) Quit

Please choose from the above actions: 5
You entered: 5
Displaying 1 item:

Frozen Yogurt : Berry Delight
Price         : $5.48
Yogurt        : vanilla
Topping       : blueberries, blackberries, strawberries


Actions:
1) Add a salad
2) Add a sandwich
3) Add a frozen yogurt
4) Display an item
5) Display all items
6) Add a topping to an item
9) Quit

Please choose from the above actions: 3
You entered: 3
Please enter the name of the frozen yogurt: Plain Strawberry
You entered: Plain Strawberry
Please enter the price for the Plain Strawberry: 3.75
You entered: 3.75
Please enter the base yogurt flavor for Plain Strawberry: vanilla
You entered: vanilla
Please enter the topping to add to Plain Strawberry: Strawberries
You entered: Strawberries
Would you like to add another topping to Plain Strawberry (yes/no)? no
You entered no

Actions:
1) Add a salad
2) Add a sandwich
3) Add a frozen yogurt
4) Display an item
5) Display all items
6) Add a topping to an item
9) Quit

Please choose from the above actions: 5
You entered: 5
Displaying 2 items:

Frozen Yogurt : Berry Delight
Price         : $5.48
Yogurt        : vanilla
Topping       : blueberries, blackberries, strawberries

Frozen Yogurt : Plain Strawberry
Price         : $3.75
Yogurt        : vanilla
Topping       : Strawberries


Actions:
1) Add a salad
2) Add a sandwich
3) Add a frozen yogurt
4) Display an item
5) Display all items
6) Add a topping to an item
9) Quit

Please choose from the above actions: 9
You entered: 9
Thank you!

Add Three and List

Welcome - PUT AN ORIGINAL WELCOME MESSAGE HERE

Actions:
1) Add a salad
2) Add a sandwich
3) Add a frozen yogurt
4) Display an item
5) Display all items
6) Add a topping to an item
9) Quit

Please choose from the above actions: 2
You entered: 2
Please enter the name of the sandwich: Italian Meatball
You entered: Italian Meatball
Please enter the price for the Italian Meatball: 8.99
You entered: 8.99
Please enter the name of the side: Brussel sprouts
You entered: Brussel sprouts
Please enter the type of bread for the Italian Meatball: Flatbread
You entered: Flatbread

Actions:
1) Add a salad
2) Add a sandwich
3) Add a frozen yogurt
4) Display an item
5) Display all items
6) Add a topping to an item
9) Quit

Please choose from the above actions: 1
You entered: 1
Please enter the name of the salad: Farm Cobb
You entered: Farm Cobb
Please enter the price for the Farm Cobb: 7.12
You entered: 7.12
Please enter the name of the side: Crispy Bacon
You entered: Crispy Bacon
Please enter the dressing for the Farm Cobb: Bacon Ranch
You entered: Bacon Ranch

Actions:
1) Add a salad
2) Add a sandwich
3) Add a frozen yogurt
4) Display an item
5) Display all items
6) Add a topping to an item
9) Quit

Please choose from the above actions: 3
You entered: 3
Please enter the name of the frozen yogurt: Blackberry Cheesecake
You entered: Blackberry Cheesecake
Please enter the price for the Blackberry Cheesecake: 5.5
You entered: 5.5
Please enter the base yogurt flavor for Blackberry Cheesecake: vanilla
You entered: vanilla
Please enter the topping to add to Blackberry Cheesecake: blackberries
You entered: blackberries
Would you like to add another topping to Blackberry Cheesecake (yes/no)? yes
You entered yes
Please enter the additional topping flavor: crackers
You entered: crackers
Would you like to add another topping to Blackberry Cheesecake (yes/no)? no
You entered no

Actions:
1) Add a salad
2) Add a sandwich
3) Add a frozen yogurt
4) Display an item
5) Display all items
6) Add a topping to an item
9) Quit

Please choose from the above actions: 5
You entered: 5
Displaying 3 items:

Sandwich : Italian Meatball (on Flatbread)
Price    : $8.99
Side     : Brussel sprouts
Toppings : 

Salad    : Farm Cobb (with Bacon Ranch)
Price    : $7.12
Side     : Crispy Bacon
Toppings : 

Frozen Yogurt : Blackberry Cheesecake
Price         : $5.99
Yogurt        : vanilla
Topping       : blackberries, crackers


Actions:
1) Add a salad
2) Add a sandwich
3) Add a frozen yogurt
4) Display an item
5) Display all items
6) Add a topping to an item
9) Quit

Please choose from the above actions: 9
You entered: 9
Thank you!

Add Three and Display Each one

Welcome - PUT AN ORIGINAL WELCOME MESSAGE HERE

Actions:
1) Add a salad
2) Add a sandwich
3) Add a frozen yogurt
4) Display an item
5) Display all items
6) Add a topping to an item
9) Quit

Please choose from the above actions: 3
You entered: 3
Please enter the name of the frozen yogurt: Plain Strawberry
You entered: Plain Strawberry
Please enter the price for the Plain Strawberry: 3.75
You entered: 3.75
Please enter the base yogurt flavor for Plain Strawberry: vanilla
You entered: vanilla
Please enter the topping to add to Plain Strawberry: Strawberries
You entered: Strawberries
Would you like to add another topping to Plain Strawberry (yes/no)? no
You entered no

Actions:
1) Add a salad
2) Add a sandwich
3) Add a frozen yogurt
4) Display an item
5) Display all items
6) Add a topping to an item
9) Quit

Please choose from the above actions: 2
You entered: 2
Please enter the name of the sandwich: Club
You entered: Club
Please enter the price for the Club: 5.01
You entered: 5.01
Please enter the name of the side: Green beans
You entered: Green beans
Please enter the type of bread for the Club: Nine Grain
You entered: Nine Grain

Actions:
1) Add a salad
2) Add a sandwich
3) Add a frozen yogurt
4) Display an item
5) Display all items
6) Add a topping to an item
9) Quit

Please choose from the above actions: 1
You entered: 1
Please enter the name of the salad: Fresh Garden
You entered: Fresh Garden
Please enter the price for the Fresh Garden: 6.45
You entered: 6.45
Please enter the name of the side: Macaroni and Cheese
You entered: Macaroni and Cheese
Please enter the dressing for the Fresh Garden: Ranch
You entered: Ranch

Actions:
1) Add a salad
2) Add a sandwich
3) Add a frozen yogurt
4) Display an item
5) Display all items
6) Add a topping to an item
9) Quit

Please choose from the above actions: 5
You entered: 5
Displaying 3 items:

Frozen Yogurt : Plain Strawberry
Price         : $3.75
Yogurt        : vanilla
Topping       : Strawberries

Sandwich : Club (on Nine Grain)
Price    : $5.01
Side     : Green beans
Toppings : 

Salad    : Fresh Garden (with Ranch)
Price    : $6.45
Side     : Macaroni and Cheese
Toppings : 


Actions:
1) Add a salad
2) Add a sandwich
3) Add a frozen yogurt
4) Display an item
5) Display all items
6) Add a topping to an item
9) Quit

Please choose from the above actions: 4
You entered: 4
Please enter the name of the item to display: Garlic Bread
You entered: Garlic Bread
Sorry, could not find Garlic Bread in the list

Actions:
1) Add a salad
2) Add a sandwich
3) Add a frozen yogurt
4) Display an item
5) Display all items
6) Add a topping to an item
9) Quit

Please choose from the above actions: 4
You entered: 4
Please enter the name of the item to display: Fresh Garden
You entered: Fresh Garden
Salad    : Fresh Garden (with Ranch)
Price    : $6.45
Side     : Macaroni and Cheese
Toppings : 


Actions:
1) Add a salad
2) Add a sandwich
3) Add a frozen yogurt
4) Display an item
5) Display all items
6) Add a topping to an item
9) Quit

Please choose from the above actions: 4
You entered: 4
Please enter the name of the item to display: BLT
You entered: BLT
Sorry, could not find BLT in the list

Actions:
1) Add a salad
2) Add a sandwich
3) Add a frozen yogurt
4) Display an item
5) Display all items
6) Add a topping to an item
9) Quit

Please choose from the above actions: 4
You entered: 4
Please enter the name of the item to display: Club
You entered: Club
Sandwich : Club (on Nine Grain)
Price    : $5.01
Side     : Green beans
Toppings : 


Actions:
1) Add a salad
2) Add a sandwich
3) Add a frozen yogurt
4) Display an item
5) Display all items
6) Add a topping to an item
9) Quit

Please choose from the above actions: 4
You entered: 4
Please enter the name of the item to display: Chocolate^2 Chip Cookie Dough
You entered: Chocolate^2 Chip Cookie Dough
Sorry, could not find Chocolate^2 Chip Cookie Dough in the list

Actions:
1) Add a salad
2) Add a sandwich
3) Add a frozen yogurt
4) Display an item
5) Display all items
6) Add a topping to an item
9) Quit

Please choose from the above actions: 4
You entered: 4
Please enter the name of the item to display: Plain Strawberry
You entered: Plain Strawberry
Frozen Yogurt : Plain Strawberry
Price         : $3.75
Yogurt        : vanilla
Topping       : Strawberries


Actions:
1) Add a salad
2) Add a sandwich
3) Add a frozen yogurt
4) Display an item
5) Display all items
6) Add a topping to an item
9) Quit

Please choose from the above actions: 9
You entered: 9
Thank you!

Add Three and Add Toppings

Welcome - PUT AN ORIGINAL WELCOME MESSAGE HERE

Actions:
1) Add a salad
2) Add a sandwich
3) Add a frozen yogurt
4) Display an item
5) Display all items
6) Add a topping to an item
9) Quit

Please choose from the above actions: 2
You entered: 2
Please enter the name of the sandwich: BLT
You entered: BLT
Please enter the price for the BLT: 5.5
You entered: 5.5
Please enter the name of the side: Corn on the Cob
You entered: Corn on the Cob
Please enter the type of bread for the BLT: Whole Wheat
You entered: Whole Wheat

Actions:
1) Add a salad
2) Add a sandwich
3) Add a frozen yogurt
4) Display an item
5) Display all items
6) Add a topping to an item
9) Quit

Please choose from the above actions: 3
You entered: 3
Please enter the name of the frozen yogurt: Chocolate^2 Chip Cookie Dough
You entered: Chocolate^2 Chip Cookie Dough
Please enter the price for the Chocolate^2 Chip Cookie Dough: 3.75
You entered: 3.75
Please enter the base yogurt flavor for Chocolate^2 Chip Cookie Dough: chocolate
You entered: chocolate
Please enter the topping to add to Chocolate^2 Chip Cookie Dough: Chocolate Chip Cookie Dough
You entered: Chocolate Chip Cookie Dough
Would you like to add another topping to Chocolate^2 Chip Cookie Dough (yes/no)? yes
You entered yes
Please enter the additional topping flavor: Brownies
You entered: Brownies
Would you like to add another topping to Chocolate^2 Chip Cookie Dough (yes/no)? no
You entered no

Actions:
1) Add a salad
2) Add a sandwich
3) Add a frozen yogurt
4) Display an item
5) Display all items
6) Add a topping to an item
9) Quit

Please choose from the above actions: 1
You entered: 1
Please enter the name of the salad: Fresh Mediterranean
You entered: Fresh Mediterranean
Please enter the price for the Fresh Mediterranean: 6.99
You entered: 6.99
Please enter the name of the side: Garlic Bread
You entered: Garlic Bread
Please enter the dressing for the Fresh Mediterranean: Fresh Lemon
You entered: Fresh Lemon

Actions:
1) Add a salad
2) Add a sandwich
3) Add a frozen yogurt
4) Display an item
5) Display all items
6) Add a topping to an item
9) Quit

Please choose from the above actions: 5
You entered: 5
Displaying 3 items:

Sandwich : BLT (on Whole Wheat)
Price    : $5.5
Side     : Corn on the Cob
Toppings : 

Frozen Yogurt : Chocolate^2 Chip Cookie Dough
Price         : $4.24
Yogurt        : chocolate
Topping       : Chocolate Chip Cookie Dough, Brownies

Salad    : Fresh Mediterranean (with Fresh Lemon)
Price    : $6.99
Side     : Garlic Bread
Toppings : 


Actions:
1) Add a salad
2) Add a sandwich
3) Add a frozen yogurt
4) Display an item
5) Display all items
6) Add a topping to an item
9) Quit

Please choose from the above actions: 6
You entered: 6
Please enter the name of the item (to add a topping to): Fresh Mediterranean
You entered: Fresh Mediterranean
Please enter the topping to add to Fresh Mediterranean: Salt
You entered: Salt

Actions:
1) Add a salad
2) Add a sandwich
3) Add a frozen yogurt
4) Display an item
5) Display all items
6) Add a topping to an item
9) Quit

Please choose from the above actions: 6
You entered: 6
Please enter the name of the item (to add a topping to): Fresh Mediterranean
You entered: Fresh Mediterranean
Please enter the topping to add to Fresh Mediterranean: Pepper
You entered: Pepper

Actions:
1) Add a salad
2) Add a sandwich
3) Add a frozen yogurt
4) Display an item
5) Display all items
6) Add a topping to an item
9) Quit

Please choose from the above actions: 6
You entered: 6
Please enter the name of the item (to add a topping to): Chocolate^2 Chip Cookie Dough
You entered: Chocolate^2 Chip Cookie Dough
Please enter the topping to add to Chocolate^2 Chip Cookie Dough: Hot fudge
You entered: Hot fudge

Actions:
1) Add a salad
2) Add a sandwich
3) Add a frozen yogurt
4) Display an item
5) Display all items
6) Add a topping to an item
9) Quit

Please choose from the above actions: 5
You entered: 5
Displaying 3 items:

Sandwich : BLT (on Whole Wheat)
Price    : $5.5
Side     : Corn on the Cob
Toppings : 

Frozen Yogurt : Chocolate^2 Chip Cookie Dough
Price         : $4.73
Yogurt        : chocolate
Topping       : Chocolate Chip Cookie Dough, Brownies, Hot fudge

Salad    : Fresh Mediterranean (with Fresh Lemon)
Price    : $7.48
Side     : Garlic Bread
Toppings : Salt, Pepper


Actions:
1) Add a salad
2) Add a sandwich
3) Add a frozen yogurt
4) Display an item
5) Display all items
6) Add a topping to an item
9) Quit

Please choose from the above actions: 9
You entered: 9
Thank you!

Invalid Menu Action

Welcome - PUT AN ORIGINAL WELCOME MESSAGE HERE

Actions:
1) Add a salad
2) Add a sandwich
3) Add a frozen yogurt
4) Display an item
5) Display all items
6) Add a topping to an item
9) Quit

Please choose from the above actions: 5
You entered: 5
Displaying 0 items:


Actions:
1) Add a salad
2) Add a sandwich
3) Add a frozen yogurt
4) Display an item
5) Display all items
6) Add a topping to an item
9) Quit

Please choose from the above actions: 99
You entered: 99
Sorry, 99 is not a valid option.

Actions:
1) Add a salad
2) Add a sandwich
3) Add a frozen yogurt
4) Display an item
5) Display all items
6) Add a topping to an item
9) Quit

Please choose from the above actions: 89
You entered: 89
Sorry, 89 is not a valid option.

Actions:
1) Add a salad
2) Add a sandwich
3) Add a frozen yogurt
4) Display an item
5) Display all items
6) Add a topping to an item
9) Quit

Please choose from the above actions: -1
You entered: -1
Sorry, -1 is not a valid option.

Actions:
1) Add a salad
2) Add a sandwich
3) Add a frozen yogurt
4) Display an item
5) Display all items
6) Add a topping to an item
9) Quit

Please choose from the above actions: 9
You entered: 9
Thank you!

Bonuses

  1. Run your code in a debugger (for example, in BlueJ) and include a screenshot that shows instance variables for your Salad class. For the name of the salad, use your own name.
  2. Submit your project (.java files to codePost and the rubric to CougarVIEW) at least 24 hours before the due time and earn at least 90% of points.

Rubric:

Points      Item
----------  --------------------------------------------------------------
_____ / 15  Style
            + Code is indented correctly
            + Methods should be no longer than 1 page
            + Documentation: (written for another software developer)
              * All source code files include Javadoc header block with description, @author, @version, etc.
              * Javadoc (with block tags, for example @param, @return) before each method
              * All non-trivial variables are commented
              * Comments included before major portions of code
_____ / 30  ArrayList (creation and use)
_____ / 10  Inheritance hierarchy
_____ / 15  Appropriate fields and methods in base class and child classes (salad, sandwich and frozen yogurts) (uses inherited members appropriately)
_____ / 28  Input / Output Tests
_____ /  5  Debugger screenshot (bonus)
_____ /  5  Submitted 1+ days early (bonus)
_____ /  2  Completed rubric (estimates for each line including hours spent)


_____ /100  Total


_____  Approximate number of hours spent

I, (REPLACE WITH YOUR FULL NAME), affirm that the code that I submitted is my own work and that I did not receive help that was not authorized by the instructor.

Copy and paste this rubric into a rubric-MenuItems.txt file (not a .docx, .doc nor .rtf file). Think of this as a checklist to ensure that you receive the maximum points possible. For each grade item, fill in your estimate for the grade you deserve. Additionally, include your estimate of how many hours your spent. Lastly, replace, "(REPLACE WITH YOUR FULL NAME)" with your full name to indicate that what you are submitting is entirely your own work.

Submission

The submission process has two parts:

  1. codePost

    Submit your Menu class and your 4+ other classes to codePost.io. Note, codePost will only require Menu.java, but you need to also upload the other 4+ .java files otherwise it can not compile and run your code. To register for a free codePost account, please follow these instructions. You can submit to codePost multiple times if you want. Only your last submission will be graded. Watch this short video for a demonstration of submitting an assignment and reviewing the results:
    YouTube video: codePost: Submission and Checking Results Thumbnail

  2. CougarVIEW

    Submit your rubric-MenuItems.txt to the appropriate Assignment tab/folder in CougarVIEW. This is required to receive detailed graded feedback on your project. If you resubmit your rubric, this will effectively replace your previous submission.

Notes

  1. Start small and iteratively build off of a successful base. For example, get the main loop working. Verify that it's working. Then, work on action 3 and run it. Then, implement action 5 and add in some frozen yogurts and verify that they're in your ArrayList. Now, upload it to codePost and it should pass one of the tests. Get it to pass the first test before moving on. Then, implement action 4 and run it.
  2. Make sure to look carefully at rounding. Only round the displayed values and not the stored values. Round all money values to 2 decimal places when displaying them.

Help

  1. Getting Help: This project sometimes takes students many, many hours. Please promise yourself that you will reach out to the CS Tutors or your instructor for help if you have already spent 10 or more hours on the project or if you have been stuck for more than 1 hour.
  2. Only have one Scanner object in your program.
  3. If you are looking into what's wrong with you output and codePost is reporting "Log length exceeded error", then let me suggest some options:
    1. You could temporarily comment out the menu to reduce that amount of output. Do NOT comment out the part that has:
      Please choose from the above actions: 
      because "choose" is required by codePost.
  4. codePost uses Java version 8. You are required to not use Java syntax that requires a newer version.

Challenges (worth 0 points)

  1. Add in an action 7 that removes a specified item
  2. Add in an action 8 that sorts the items
  3. Instead of using a StringBuilder or StringBuffer to store the toppings, use an ArrayList. Furthermore, do not add in an additional topping if it already exists in the list.