Grade Table: Task Executable Jar file is created, Programming Guidelines are fol
ID: 3914618 • Letter: G
Question
Grade Table:
Task
Executable Jar file is created, Programming Guidelines are followed, and Report with screenshots is created
Menultem and sub classes show use inheritance
Points
25
25
Menu functions as described below
25
Order functions as described below
25
Main method functions as described below
25
TOTAL (Points Possible)
125
Instructions:
Create an interactive command line program in Java that functions as a point of sale System for a Restaurant. Since this is an interactive program you will need to use the Scanner class to enable getting input from the user. For full credit the following classes need to be created:
Menultem Abstract class that Entree, Dessert, and Drink inherit from. This class should have three attributes: String name, double price, and String orderCode. Each attribute should have appropriate setters and getters.
Drink Concrete class that inherits from Menultem. This class should add one attribute: char size. Add setters and getters for any new attributes.
Entree Concrete class that inherits from Menultem. This class gains one additonal attribute:
boolean vegetarian. Add setters and getters for the new attribute.
Dessert Concrete class that inherits from Menultem. This class does not gain any new attributes but may be instantiated.
Menu Concrete class that contains an ArrayList of Menultems. This class will need methods to:
list the items of the menu
add an item to the menu
get an item from the menu by the orderCode
Ticket A concrete class that contains an ArrayList of Menultems. This class should have methods to:
tab out: print the current order to the screen and show the total cost of the items
ordered
view order: list the items currently ordered
add item to order by order code
delete order: old order is deleted and new order started (essentially clearing the array list)
Driver This class should contain the main method. It should create a Menu and Menultems (make up your own restaurant and items. Have at least five each of the concrete items: Entree,
Drink, and Side). It should present a simple command line interface that allows the user to:
Show the menu
Show the contents of the current ticket
Total the ticket (get the total tab)
Add an item to the current ticket (will show menu and query the user to input an
orderCode)
Delete the ticket
Quit the program
Help (displays a full list of the commands)
Most of these commands will be calls to the methods that are built into the Menu and Order objects. The program should have a help option.
Task
Executable Jar file is created, Programming Guidelines are followed, and Report with screenshots is created
Menultem and sub classes show use inheritance
Points
25
25
Menu functions as described below
25
Order functions as described below
25
Main method functions as described below
25
TOTAL (Points Possible)
125
Explanation / Answer
MenuItems.java
----------
package menu;
abstract class MenuItems {
private String name;
private double price;
private int orderCode;
public MenuItems(String name, double price, int orderCode) {
this.name = name;
this.price = price;
this.orderCode = orderCode;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public double getPrice() {
return price;
}
public void setPrice(double price) {
this.price = price;
}
public int getOrderCode() {
return orderCode;
}
public void setOrderCode(int orderCode) {
this.orderCode = orderCode;
}
@Override
public String toString() {
return "MenuItems [Item :" + name + ", Price :" + price + ", orderCode :" + orderCode + "]";
}
}
------------------------------------
Dessert.java
------------
package menu;
public class Dessert extends MenuItems{
public Dessert(String name, double price, int orderCode) {
super(name, price, orderCode);
// TODO Auto-generated constructor stub
}
}
----------------------------------------------------------------
Drink.java
--------
package menu;
public class Drink extends MenuItems {
private char size;
public Drink(String name, double price, int orderCode) {
super(name, price, orderCode);
// TODO Auto-generated constructor stub
}
public char getSize() {
return size;
}
public void setSize(char size) {
this.size = size;
}
}
--------------------------------------------
Entree.java
----------
package menu;
public class Entree extends MenuItems {
private boolean vegetarian;
public Entree(String name, double price, int orderCode) {
super(name, price, orderCode);
// TODO Auto-generated constructor stub
}
public boolean isVegetarian() {
return vegetarian;
}
public void setVegetarian(boolean vegetarian) {
this.vegetarian = vegetarian;
}
}
--------------------------------
Menu.java
-----------
package menu;
import java.util.ArrayList;
public class Menu {
private String restaurantName;
private ArrayList<MenuItems> menuItemsList = new ArrayList< >(); //should I name within <>
public String getRestaurantName() {
return restaurantName;
}
public void setRestaurantName(String restaurantName) {
this.restaurantName = restaurantName;
}
public void addMenuItem(MenuItems menuItems) {
menuItemsList.add(menuItems);
}
public String toString() {
String str;
str = "Restaurant Name: " + restaurantName;
for (MenuItems m : menuItemsList) {
str += " " + m;
}
return str;
}
}
--------------------------------------------------------
Ticket.java.java
---------
package menu;
import java.util.ArrayList;
public class Ticket {
private int tableNumber;
private ArrayList<MenuItems> menuItemList = new ArrayList<MenuItems>();
public ArrayList<MenuItems> getMenuItemList() {
return menuItemList;
}
public void setMenuItemList(ArrayList<MenuItems> menuItemList) {
this.menuItemList = menuItemList;
}
public int getTableNumber() {
return tableNumber;
}
public void setTableNumber(int tableNumber) {
this.tableNumber = tableNumber;
}
public double getTotal(){
double totalPrice = 0;
for(MenuItems m : menuItemList) {
totalPrice += m.getPrice();
}
return totalPrice;
}
public String toString(){
String str;
str = "Table Number: " + tableNumber;
for (MenuItems m : menuItemList) {
str += " " + m;
}
return str;
}
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.