答答租車系統-感覺寫的好亂啊,還有很多異常都沒處理,等著我再寫個第二版

TigerJin發表於2021-09-09
package com.meituan.qa.zonghelianxi;

/**
 * Created by sunfang on 2017/10/6.
 */
public abstract class Car {
     int carType;
     float pricePerDay;
     String name;

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getCarType() {
        return carType;
    }

    public void setCarType(int carType) {
        this.carType = carType;
    }

    public float getPricePerDay() {
        return pricePerDay;
    }

    public void setPricePerDay(float pricePerDay) {
        this.pricePerDay = pricePerDay;
    }
    public abstract void showInfo();

}
package com.meituan.qa.zonghelianxi;

/**
 * Created by sunfang on 2017/10/6.
 */
public class Truck extends Car{
    private int cargoNum;

    public int getCargoNum(){
        return cargoNum;
    }
    public void setCargoNum(int cargoNum){
        this.cargoNum=cargoNum;
    }

    public Truck(int cargoNum,int carType,float pricePerDay,String name){
    this.cargoNum=cargoNum;
    this.carType=carType;
    this.pricePerDay=pricePerDay;
    this.name=name;
    }

    public Truck(){

    }

    @Override
    public  void showInfo(){
        System.out.println(this.getName()+"t"+this.getPricePerDay()+"t"+"載貨:"+getCargoNum());
    }

}
package com.meituan.qa.zonghelianxi;

import com.meituan.qa.springtest.Cat;
import netscape.security.PrivilegeTable;

/**
 * Created by sunfang on 2017/10/6.
 */
public class PrivateCar extends Car {
    private int passengersNum;

    public int getPassengersNum() {
        return passengersNum;
    }

    public void setPassengersNum(int passengersNum) {
        this.passengersNum = passengersNum;
    }

    public PrivateCar(int passengersNum,int carType,float pricePerDay,String name){
        this.passengersNum=passengersNum;
        this.carType=carType;
        this.pricePerDay=pricePerDay;
        this.name=name;
    }
    public PrivateCar(){}

    @Override
    public  void showInfo(){
        System.out.println(this.getName()+"t"+this.getPricePerDay()+"t"+"載客:"+getPassengersNum());
    }

}
package com.meituan.qa.zonghelianxi;

/**
 * Created by sunfang on 2017/10/6.
 */
public class PickUp extends Car {
    private int cargoNum;
    private int passengersNum;

    public int getCargoNum() {
        return cargoNum;
    }

    public void setCargoNum(int cargoNum) {
        this.cargoNum = cargoNum;
    }

    public int getPassengersNum() {
        return passengersNum;
    }

    public void setPassengersNum(int passengersNum) {
        this.passengersNum = passengersNum;
    }

    public PickUp(int cargoNum,int passengersNum,int carType,float pricePerDay,String name){
        this.cargoNum=cargoNum;
        this.passengersNum=passengersNum;
        this.carType=carType;
        this.pricePerDay=pricePerDay;
        this.name=name;
    }
    public PickUp(){}

    @Override
    public  void showInfo(){
        System.out.println(this.getName()+"t"+this.getPricePerDay()+"t"+"載貨:"+this.getCargoNum()+" 載客:"+this.getPassengersNum());
    }

}
package com.meituan.qa.zonghelianxi;

import java.util.Scanner;

/**
 * Created by sunfang on 2017/10/6.
 */
public class RentCarSystem {
    public static void main(String[] args) {
        System.out.println("歡迎使用答答租車系統:n"+"您是否要租車:1是 0否");
        float rentMoney=0;

        Scanner scanner=new Scanner(System.in);
//        for (int i=0;i

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/2144/viewspace-2808112/,如需轉載,請註明出處,否則將追究法律責任。

相關文章