/**
* Created by Administrator on 2018/12/10.
*/
public class WuMingFen {
//属性
String theMa; //面码
int quantity; //粉的分量
boolean likeSoup; //是否带汤
//1、创建构造方法
public WuMingFen(String theMa,int quantity,boolean likeSoup) {
this.theMa=theMa;
this.quantity=quantity;
this.likeSoup=likeSoup;
}
//2、重载构造方法
public WuMingFen(String theMa,int quantity) {
this.theMa=theMa;
this.quantity=quantity;
}
//3、show方法控制台输入配方
public void check(){
if (likeSoup) {
System.out.println(theMa+"、"+quantity+"、带汤");
}else {
System.out.println(theMa + "、" + quantity + "、不带汤");
}
}
}
**********************************************
/**
* Created by Administrator on 2018/12/10.
测试类
*/
public class Text {
public static void main(String[] args) {
WuMingFen f1=new WuMingFen("牛肉",3,true);
WuMingFen f2=new WuMingFen("牛肉",2);
WuMingFen f3=new WuMingFen("酸辣面码",2,true);
f1.check();
f2.check();
f3.check();
}
}