| 
 
| class Demo0 { 
 public static void main (String[]args) {
 Phone P = new Phone();
 P.setBrand ("iphone");
 P.setPrice (5288);
 System.out.println(P.getBrand()+"的价格是:"+P.getPrice());
 P.call();
 P.playGame();
 P.sendMessage();
 
 
 Car c1 = new Car();
 c1.color = "红色";
 c1.num = 4;
 
 System.out.print(c1.num+"个轮子的"+c1.color);
 c1.run();
 
 }
 
 }
 
 class Phone {
 private String brand;
 private int price;
 
 public void call (){
 System.out.println("打电话");
 }
 
 public void sendMessage (){
 System.out.println("发信息");
 }
 
 public void playGame (){
 System.out.println("打游戏");
 }
 
 public void setBrand(String brand) {
 this.brand = brand;
 }
 
 public String getBrand() {
 return brand;
 }
 
 public void setPrice(int price) {
 this.price = price;
 }
 
 public int getPrice() {
 return price;
 }
 
 }
 
 
 
 class Car {
 String color;
 int num;
 public void run(){
 System.out.println("汽车在跑");
 }
 
 }
 基本算是今天讲的代码量了,不知道明天的构造怎么样,有正在学面向对象的吗?或者有师兄师姐教教经验吗?求长期交流的
 | 
 |