package com.imooc.zuche;
import java.util.Scanner;
class passengerCar extends Car{//载客车
private double peopleCapacity;
public passengerCar(String name,double rent,double peopleCapacity){
this.name=name;
this.rent=rent;
this.peopleCapacity=peopleCapacity;
}
public double getPeopleCapacity() {
return peopleCapacity;
}
public void setPeopleCapacity(double peopleCapacity) {
this.peopleCapacity = peopleCapacity;
}
}
class PickUp extends Car{//皮卡
private double cargoCapacity;//载客量
private double peopleCapacity;//载货量
public PickUp(String name,double rent,double cargoCapacity,double peopleCapacity){
this.name=name;
this.rent=rent;
this.cargoCapacity=cargoCapacity;
this.peopleCapacity=peopleCapacity;
}
public double getCargoCapacity() {
return cargoCapacity;
}
public void setCargoCapacity(double cargoCapacity) {
this.cargoCapacity = cargoCapacity;
}
public double getPeopleCapacity() {
return peopleCapacity;
}
public void setPeopleCapacity(double peopleCapacity) {
this.peopleCapacity = peopleCapacity;
}
}
class Truck extends Car{//货车
private double cargoCapacity;
public Truck(String name,double rent,double cargoCapacity){
this.name=name;
this.rent=rent;
this.cargoCapacity=cargoCapacity;
}
public double getCargoCapacity() {
return cargoCapacity;
}
public void setCargoCapacity(double cargoCapacity) {
this.cargoCapacity = cargoCapacity;
}
}
class tes{
public static void main(String[] args) {
Car[] carsForRent={//定义车辆类型
new passengerCar("奥迪A4",500,4),
new passengerCar("马自达6",400,4),
new PickUp("皮卡6",450,4,2),
new Truck("松花江",400,4),
new Truck("斯太尔",1000,20)
};
System.out.println("欢迎使用答答租车系统");
System.out.println("您是否要租车:1.租车 2.退出");
Scanner scan=new Scanner(System.in);
String input=scan.next();
if(input.equals("1")){
System.out.println("您可租车的类型及其价目表");
System.out.println("序号\t名称\t租金\t容量");
}
}
}
森特
相关分类