public class Vehicle String color; int seats;座位数 String startMode;启动方式 public VehicleString color int seats String startMode thiscolor = color; thisseats = seats; thisstartMode = startMo
public class Test { public static void main(String[] args) { Car car1 = new Car("Red", 4, "Key", 20000, 200); Plane plane1 = new Plane("Blue", 200, "Button", 500000, 800);
System.out.println("Car color: " + car1.getColor());
System.out.println("Car seats: " + car1.getSeats());
System.out.println("Car start mode: " + car1.getStartMode());
System.out.println("Car price: " + car1.price);
System.out.println("Car speed: " + car1.speed);
System.out.println("Plane color: " + plane1.getColor());
System.out.println("Plane seats: " + plane1.getSeats());
System.out.println("Plane start mode: " + plane1.getStartMode());
System.out.println("Plane price: " + plane1.price);
System.out.println("Plane speed: " + plane1.speed);
}
原文地址: http://www.cveoy.top/t/topic/hSkG 著作权归作者所有。请勿转载和采集!