Question

Pop’s Pie Shop wants you to help computerize its ever-changing menu. Here’s an example of the...

Pop’s Pie Shop wants you to help computerize its ever-changing menu. Here’s an example of the delicious items that Pop’s has to offer:

Here is what we are starting with today:

Savory:

Savory Mince & Cheese

Pork & Peach

BBQ C

urried Lamb & Spinach

Chicken & Kumara

Smoked Salmon, Leek & Potato

Thai Butternut Curry (vegan)

Sausage Roll

Spinach & Cheese

Roll Beef Pasty

Sweet Pie by the slice:

Banoffee

Blueberry Apple (vegan)

Buttermilk & Raspberry

Chocolate Chess

Chocolate Raspberry Cream

Coconut Cream

Dutch Apple

Lemon Meringue

Mock Turtle (vegan)

Sweet Treats:

Anzac Biscuit

Caramel Blondie

Cherry Pecan Brownie

Chocolate Peppermint Cookie

Lamington

Lemon Coconut Cake

Mellowpuff

Yo Yo

As you can see, there are three categories in the menu each containing food items. A single, basic food item has a name, a designation if it’s suitable for vegan or other special diets, and a category (Savory, Sweet Pie, or Sweet Treat). In addition, Pop’s pies are so “pop”ular (get it?) that he would like a field to indicate if a Food Item is available or not, so that he can update the menu when an item is sold out. What data types comprise the fields in a FoodItem class?

The other class that needs to be designed represents the menu of the day at Pop’s Pie Shop. The name of the Java class is Menu. The important characteristics of a Menu for Pop’s application are the three collections of FoodItems and the date. The menu to be displayed to customers is a list of all the available food items in each category, so the Menu class needs a method that will return a string representation of the current menu that includes the date.

The PieShop class contains the main method and is responsible for reading in the text file that contains the list of food items for the menu. The name of the file is to be read as a command line argument. (Failure to use command line arguments will result in a severe point penalty.) The food items are listed in the text file one item per line. The line is formatted with the name, menu category, special diet information, and availability all separated by a colon (:). For example:

Savory Mince & Cheese : savory : none : y

Blueberry Apple : sweet pie : vegan : y

Mellowpuff : sweet treat : none : n

The program will create FoodItem objects from the data in the text files and populate the day’s menu with those FoodItems that are available. (Failure to create these objects in your program will greatly reduce the number of points that you earn for the project.) Once this has been done, the program will display today’s menu with a header, the current date, and the three categories of FoodItems listed separately. After displaying the menu for the day, the program will provide the following options:

1 – Update an existing item on the menu

2 – Save the menu

3 – Close the program

For the first option, the program will prompt the user for the category and name of the item. If the item is included in the menu, then provide the option to change it from available to unavailable or from unavailable to available. Option 2 will save the current menu, including any changes made via option 1, to a file named menu.out.

Please use Drjava for this program. As long as the program runs correctly, extra work doesn't need to be added. Please make it as elementary as possible. I'd just love to see your programming code from mine to learn more. Thank you so much!

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Excutable code:

import java.io.BufferedReader;
import java.io.FileInputStream;
import java.io.InputStreamReader;
import java.sql.Date;
import java.util.Scanner;

public class PieShop {
public static void main(String[] args) {
int run = 0;
Scanner scanner = new Scanner(System.in);
FoodItem fd1 = new FoodItem("Savory Mince & Cheese", "Savory");
FoodItem fd2 = new FoodItem("Banoffee", "Sweet Pie by the slice");
FoodItem fd3 = new FoodItem("Anzac Biscuit", "Sweet Treats");
Date date = new Date(run);
Menu menu = new Menu();
System.out.println("Menu on " + menu.getMenuDate());
try {
FileInputStream fstream = new FileInputStream(args[0]);
BufferedReader br = new BufferedReader(new InputStreamReader(fstream));
String strLine;

while ((strLine = br.readLine()) != null) {

System.out.println(strLine);

}

br.close();
while (true) {
try {
System.out.println("1 – Update an existing item on the menu\n" + "2 – Save the menu\n"
+ "3 – Close the program");
run = scanner.nextInt();
} catch (Exception e) {
break;
}
switch (run) {
case 1:
System.out.println("case 1");
break;
case 2:
System.out.println("case 2");
break;
default:
System.out.println("case 3");
return;
}
}
} catch (Exception e) {
System.out.println("No file provided");
return;
}
}
}
public class FoodItem {
String name;
String description;

public FoodItem() {

}

public FoodItem(String name, String description) {
this.name = name;
this.description = description;
}

public void setFoodItem(String name, String description) {
this.name = name;
this.description = description;
}

public String getFoodItemName() {
return this.name;
}

public String getFoodItemDescription() {
return this.name;
}
}

Add a comment
Know the answer?
Add Answer to:
Pop’s Pie Shop wants you to help computerize its ever-changing menu. Here’s an example of the...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Can someone please help me with this Python code? Thank you in advance, Zybooks keeps giving me e...

    Can someone please help me with this Python code? Thank you in advance, Zybooks keeps giving me errors. Thanks in advance!! This program extends the earlier "Online shopping cart" program. (Consider first saving your earlier program). (1) Extend the ItemToPurchase class to contain a new attribute. (2 pts) item_description (string) - Set to "none" in default constructor Implement the following method for the ItemToPurchase class. print_item_description() - Prints item_description attribute for an ItemToPurchase object. Has an ItemToPurchase parameter. Ex. of...

  • Need three seperate files. ShoppingCartManager.java ShoppingCart.java ItemsToPurchase.java These are from part 1 what do you mean...

    Need three seperate files. ShoppingCartManager.java ShoppingCart.java ItemsToPurchase.java These are from part 1 what do you mean by deep study 7.25 LAB*: Program: Online shopping cart (Part 2) Note: Creating multiple Scanner objects for the same input stream yields unexpected behavior. Thus, good practice is to use a single Scanner object for reading input from System.in. That Scanner object can be passed as an argument to any methods that read input This program extends the earlier Online shopping cart program (Consider...

  • 4.18 Ch 7 Program: Online shopping cart (continued) (C++) This program extends the earlier "Online shopping...

    4.18 Ch 7 Program: Online shopping cart (continued) (C++) This program extends the earlier "Online shopping cart" program. (solution from previous lab assignment is provided in Canvas). (1) Extend the ItemToPurchase class per the following specifications: Parameterized constructor to assign item name, item description, item price, and item quantity (default values of 0). (1 pt) Public member functions SetDescription() mutator & GetDescription() accessor (2 pts) PrintItemCost() - Outputs the item name followed by the quantity, price, and subtotal PrintItemDescription() -...

  • I need help with this assignment, can someone HELP ? This is the assignment: Online shopping...

    I need help with this assignment, can someone HELP ? This is the assignment: Online shopping cart (continued) (C++) This program extends the earlier "Online shopping cart" program. (Consider first saving your earlier program). (1) Extend the ItemToPurchase class per the following specifications: Parameterized constructor to assign item name, item description, item price, and item quantity (default values of 0). (1 pt) Public member functions SetDescription() mutator & GetDescription() accessor (2 pts) PrintItemCost() - Outputs the item name followed by...

  • I am struggling with a program in C++. it involves using a struct and a class...

    I am struggling with a program in C++. it involves using a struct and a class to create meal arrays from a user. I've written my main okay. but the functions in the class are giving me issues with constructors deconstructors. Instructions A restaurant in the Milky way galaxy called “Green Alien” has several meals available on their electronic menu. For each food item in each meal, the menu lists the calories per gram and the number of grams per...

  • Assignment Instructions In cell B10, use the COUNTIF function to count the number of Specialty pl...

    Assignment Instructions In cell B10, use the COUNTIF function to count the number of Specialty plant types in the Category column. 9 In cell H13, type Stock Level. In cell H14, enter an IF function to determine the items that must be ordered. If the Quantity in Stock is less than 50, the Value if true is Order. Otherwise the Value if false is OK. Fill the formula down through cell H42. 10 Apply Conditional Formatting to the Stock Level...

  • could you please help me with this problem, also I need a little text so I...

    could you please help me with this problem, also I need a little text so I can understand how you solved the problem? import java.io.File; import java.util.Scanner; /** * This program lists the files in a directory specified by * the user. The user is asked to type in a directory name. * If the name entered by the user is not a directory, a * message is printed and the program ends. */ public class DirectoryList { public static...

  • Additional code needed: PartA: BurgerOrder class (1 point) Objective: Create a new class that represents an...

    Additional code needed: PartA: BurgerOrder class (1 point) Objective: Create a new class that represents an order at a fast-food burger joint. This class will be used in Part B, when we work with a list of orders. As vou work through this part and Part B, draw a UML diagram of each class in using the UML drawing tool 1) Create a new Lab5TestProject project in Netbeans, right-click on the lab5testproject package and select New>Java Class 2) Call your...

  • Please read the article and answer about questions. You and the Law Business and law are...

    Please read the article and answer about questions. You and the Law Business and law are inseparable. For B-Money, the two predictably merged when he was negotiat- ing a deal for his tracks. At other times, the merger is unpredictable, like when your business faces an unexpected auto accident, product recall, or government regulation change. In either type of situation, when business owners know the law, they can better protect themselves and sometimes even avoid the problems completely. This chapter...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT