我想在客人数组中添加一个客人,你们能看到做错了什么,或者我不能调用一个字符串、构造函数、构造函数吗?
错误说:the method addGuest(Guest) in the type table is not applicable for the argument ( String, Tea,Cake)
。我正在尝试将客人放入阵列
这是我的代码。
guests[0]=table.addGuest("Alice",new Tea("RoseShip Tea",false,true),new Cake("Chocolate Sponge"));
Guest 类的构造函数是这样的:
public Guest(String name, Tea newTea, Cake newCake)
Tea 类的构造函数是:
public Tea(String name, boolean suiker, boolean melk)
类蛋糕:
public Cake(String name) {
this.name = name;
}
addGuest 方法:
public void addGuest(Guest guest)
我想做的是:
guests[0]=table.addGuest(new Guest("Alice"),new Tea("RoseShip Tea",false,true),new Cake("Chocolate Sponge"));