public class Demo_phone {
public static void main(String[]args){
phone p1=new phone();
p1.setBrand("三星");
p1.setPrice(5200);
System.out.println(p1.getBrand()+"...."+p1.getPrice());
p1.call();
p1.sendMessage();
p1.playGame();
}
}
//手机类:
//属性:品牌brand 价格price
//行为:打电话call,发短信sendMessage,玩游戏playGame
class phone{//java bean类
private String brand;
private int price;
public void setBrand(String brand){//设置品牌
this.brand=brand;
}
public String getBrand(){//获取品牌
return this.brand;
}
public void setPrice(int price){//设置价格
this.price=price;
}
public int getPrice(){//获取价格
return this.price;
}
public void call(){
System.out.println("打电话");
}
public void sendMessage(){
System.out.println("发短信");
}
public void playGame(){
System.out.println("玩游戏");
}
}