class Demo2_phone {
public static void main(String[] args) {
phone p = new phone();
p.brand = "三星"; //赋值
p.price = 3200; //赋值
System.out.println(p.brand + "..."+p.price); //打印
p.call();
p.sendMessage();
p.playGame();
}
}
class phone { //手机类:phone
String brand; //属性:brand品牌
int price; //属性:price价格
public void call() { //行为:call打电话
System.out.println("打电话");
}
public void sendMessage() { //行为:sendMessage发信息
System.out.println("发信息");
}
public void playGame() { //行为:playGame玩游戏
System.out.println("玩游戏");
}
}
|
|