ITPub博客

首页 > IT职业 > IT职场 > 答答租车系统-感觉写的好乱啊,还有很多异常都没处理,等着我再写个第二版

答答租车系统-感觉写的好乱啊,还有很多异常都没处理,等着我再写个第二版

IT职场 作者:TigerJin 时间:2021-09-09 09:06:35 0 删除 编辑
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博客 ” ,链接:https://blog.itpub.net/2144/viewspace-2808112/ ,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论

注册时间:2020-06-28

  • 博文量
    494
  • 访问量
    25806