/*
手机的
属性:品牌(brand)价格(price)
行为:打电话(call)发信息(sentMessage)玩游戏(playGame)
*/
class Phone_Test {
public static void main(String[] args) {
Phone p = new Phone();
p.brand = "锤子";
p.price = 1999;
System.out.println(p.brand+"..."+p.price);
p.call();
p.sentMessage();
p.playGame();
}
}
class Phone {
String brand;
int price;
public void call () {
System.out.println("打电话");
}
public void sentMessage () {
System.out.println("发信息");
}
public void playGame() {
System.out.println("玩游戏");
}
}
|
|