/** * Objects of this class represent menu items, including * the restaurant, the name of the menu item, and the price. * * @author Alyce Brady * @version 15 April 2020 */ public class MenuItem { // State: instance variables private String location; private String menuItemName; private double priceOfItem; /** Stores information about a menu item from a specific restaurant. * @param restaurant the restaurant that has this item * @param itemName the name of the menu item * @param price the menu item's price at this restaurant */ public MenuItem(String restaurant, String itemName, double price) { this.location = restaurant; this.menuItemName = itemName; this.priceOfItem = price; } /** Returns the restaurant carrying this menu item. * @return restaurant name */ public String getRestaurant() { return this.location; } /** Returns the name of this menu item. * @return item name */ public String getItemName() { return this.menuItemName; } /** Returns the price of this menu item. * @return price */ public double getPrice() { return this.priceOfItem; } /** Returns the information about this menu item in a single string. * @return a string containing the restaurant name, menu item name, and price */ public String toString() { return this.location + ": " + this.menuItemName + " (" + this.priceOfItem + ")"; } }