设计一个外卖点餐系统,要求餐厅管理员可以输入菜品信息用Java实现部分代码
时间: 2024-05-19 14:12:23 浏览: 23
以下是部分Java代码实现:
public class FoodItem {
private String name;
private String description;
private double price;
// Constructor
public FoodItem(String name, String description, double price) {
this.name = name;
this.description = description;
this.price = price;
}
// Getters and setters
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
public double getPrice() {
return price;
}
public void setPrice(double price) {
this.price = price;
}
}
public class RestaurantManager {
private List<FoodItem> menu;
// Constructor
public RestaurantManager(List<FoodItem> menu) {
this.menu = menu;
}
// Methods
public void addFoodItem(FoodItem foodItem) {
menu.add(foodItem);
}
public void removeFoodItem(FoodItem foodItem) {
menu.remove(foodItem);
}
public List<FoodItem> getMenu() {
return menu;
}
public void printMenu() {
for (FoodItem item : menu) {
System.out.println(item.getName() + "\t" + item.getDescription() + "\t$" + item.getPrice());
}
}
}
相关推荐
![7z](https://img-home.csdnimg.cn/images/20210720083312.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)