//定义用户类 class Consumer { //定义成员变量用户名name String name; Consumer(name) { this.nanme=name; } } //定义预定餐桌号 class Desk { //定义成员变量餐桌号num int num; Desk(num) { this.num=num; } } //定义预定餐具 class TableWare { //定义成员变量餐具tool,tool2 String tool1; String tool2; TableWare(tool1,tool2) { this.tool1=tool1; this.tool2=tool2; } } //定义预定菜单 class Meal() { //定义成员变量菜名fish,rice String fish; String rice; Meal(fish,rice) { this.fish=fish; this.rice=rice; } } class RenDemo { public static void main(String[] args) { Consumer con=new Consumer("张XX"); Desk desk=new Desk(12); TableWare tw=new TableWare(cs1,sn1); Meal ml=new Meal(fish1,rice1); System.out.println("定餐人"+con.name+"座位号"+desk.num+"预定餐具"+tw.tool1+" "+tw.tool2 +"预定餐"+ml.fish+" "+ml.rice); } } |