手机类练习题
案例:
DemoPhone1类:
//成员变量
String brand;//品牌
int price;//价格
String color;//颜色
//成员方法
public void call(String who){
System.out.println("给"+who+"打电话");
}
public void Sms(){
System.out.println("群发短信");
}
PhoneTest2类:
public static void main(String[] args) {
DemoPhone1 dp = new DemoPhone1();
dp.brand="苹果13";
dp.price=10000;
dp.color="白色";
System.out.println(dp.brand);
System.out.println(dp.price);
System.out.println(dp.color);
dp.call("易烊千玺");
dp.Sms();
}
标签:练习题,String,System,DemoPhone1,println,手机,dp,out From: https://www.cnblogs.com/shenziyi/p/16618769.html