所以我的问题直接针对我的作业。在你问之前,是的,我看过其他问题,我已经看过java文档来尝试和帮助我,但我只理解这么多..抽象概念作业
你已经成为一家餐厅大亨。你拥有几个快餐连锁店。但是,您现在需要制定一个标准,即所有的快餐连锁店都必须遵循这一标准,以便让您的软件全面统一。所有餐馆都会有相同的规则。
创建抽象类的命名餐厅
创建函数/方法调用时,将打印的餐厅的名字。
创建一个名为总价
一个抽象函数/方法创建一个抽象函数/方法命名菜单项
创建一个抽象函数/方法的名称位置
创建一个名为麦当劳类,它扩展餐厅
实施所有抽象方法
添加逻辑,以便总数价格方法/功能将给出膳食的总价格,包括6%的税收
添加一个方法,该方法返回一个名为hasPlayPlace的布尔值。在这个位置有一个playplace
创建一个构造函数,将设置在麦当劳,位置的名称,并hasPlayPlace
public class McDonalds extends Restaurant {
private String name;
private String location;
private boolean hasPlayPlace;
Scanner input = new Scanner(System.in);
public McDonalds (String name, String location, boolean hasPlayPlace) {
setName(name);
setLocation(location);
setHasPlayPlace(hasPlayPlace);
}
McDonalds location1 = new McDonalds("McDonalds", "Kirkman", false);
McDonalds location2 = new McDonalds("McDonalds 2", "International Dr.", true);
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getLocation() {
return location;
}
public void setLocation(String location){
this.location = location;
}
public boolean isHasPlayPlace() {
return hasPlayPlace;
}
public void setHasPlayPlace(boolean hasPlayPlace) {
this.hasPlayPlace = hasPlayPlace;
}
public void totalPrice() {
double totalPrice = 0;
double tax = 0.06;
totalPrice += (totalPrice * tax);
}
public void menuItems() {
//some syntax is wrong in this method
double mcChicken = 1;
double fries = 1.25;
System.out.println("1. Mc Chicken $1");
System.out.println("2. Fries $1.25");
int choice = input.nextInt();
switch (choice){
case 1: mcChicken *= tax;
case 2: fries *= tax;
}
}
public void location() {
//Don't know what's supposed to go in here.
//But I've implemented the method as I was supposed to.
}
}
返回true,所有这一切意义基本上是我要问什么。 定位方法应该怎么办? 这个班级中的吸气和吸气设备有什么用处,我做对了吗?
麦当劳现在有名字!? (当然除了麦当劳以外) – NullUserException
不要使用char作为名字,使用String。字符串文字用“”写成,所以用“麦当劳”而不是“麦当劳”(类似于吉尔曼) – Vertex
这是一个很混乱和令人困惑的问题。你打电话给你的方法怎么样?你问的是什么**问题**。 (超越“有人可以修复看起来错误的一切吗?”)你提到的菜单与任何东西有什么关系? “我可以为一个构造函数使用多个对象吗?”什么意思? – millimoose