【每日日报】第二十五天

1 今天看自学手册第六章

综合实例

1 package JieKou;
2 
3 public interface Car {
4     public String getName();
5     public String getColor();
6     public double getPrice();
7 
8 }
 1 package JieKou;
 2 
 3 public class BMW implements Car{
 4     public String getColor(){
 5         String Color="红色";
 6         return Color;
 7     }
 8     public String getName(){
 9         String name="宝马";
10         return name;
11     }
12     public double getPrice(){
13         double price=800000;
14         return price;
15     }
16 
17 }
 1 package JieKou;
 2 
 3 public class CarTest {
 4     public static void main(String args[]){
 5         Car car =new BMW();
 6         String name=car.getName();
 7         String color=car.getColor();
 8         double price=car.getPrice();
 9         System.out.println("3年后权志龙送我一辆"+name+",颜色是"+color+",价格是"+price+"万元");
10     }
11 
12 }

2 没什么问题

3 明天继续看书

原文地址:https://www.cnblogs.com/linmob/p/13418040.html