package Lianxiti; /*Bus自己的屬性:載客量、公交路線 Bus重寫父類的啟動(內容,公交車出站了)和停止(公交車到站了)的方法 */ public class Bus extends Transport { //定義Bus的成員變量 private int capacity; private int line; public... package Lianxiti;
/*Bus自己的屬性:載客量、公交路線
Bus重寫父類的啟動(內容,公交車出站了)和停止(公交車到站了)的方法
*/
public class Bus extends Transport {
//定義Bus的成員變量
private int capacity;
private int line;
public void start(){
System.out.println("公交車出站了");
}
public void stop(){
System.out.println("公交車到站了");
}
public int getCapacity() {
return capacity;
}
public void setCapacity(int capacity) {
this.capacity = capacity;
}
public int getLine() {
return line;
}
public void setLine(int line) {
this.line = line;
}
public Bus(String type, String brand, int price, int capacity, int line) {
super(type, brand, price);
this.capacity = capacity;
this.line = line;
}
public Bus(String type, String brand, int price) {
super(type, brand, price);
}
}
//以上是Transport下的一個子類
package Lianxiti;
public class Demo04 {
/**
* 創(chuàng)建測試類,分別定義以上公交車類與貨車類的對象,并賦值,及調用其啟動與停止的方法。觀查其不同。
*/
public static void main(String[] args) {
Bus b=new Bus("公交車", "青年", 100000, 200, 355);
b.。。。到這里不會了 要怎么調用謝謝大俠啦?。?!
}
} 展開