注册 登录
编程论坛 JAVA论坛

需要标识符

kurin 发布于 2017-03-16 18:49, 1423 次点击
/*实训2:编写一个手机类,具有如下功能。
手机事物:
        属性:品牌,价格,颜色...
        行为:打电话,发短信,玩游戏...

然后编写一个测试类去测试手机的功能。*/

class phone{  
  String brand ;//brand 牌子
  String   price ;
  String   color;

public void call(){
     System.out.println("打电话。");
}
public void messages(){
     System.out.println("发短信。");
}
public void games(){
     System.out.println("玩游戏。");
}
}

public class Test0602{
     pubilc static void main(String[] args){
     phone huawei=new phone();
     huawei.brand="华为p10";
     huawei.price="4000元";
     huawei.color="gold";
System.out.println(huawei.brand);
System.out.println(huawei.price);
System.out.println(huawei.color);
     huawei.call();
}
只有本站会员才能查看附件,请 登录


[此贴子已经被作者于2017-3-16 21:59编辑过]

2 回复
#2
孤独与烈酒2017-03-17 09:00
public 写错了
#3
Milogenius2017-03-19 00:33
面向对象的练习
1