第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時(shí)綁定郵箱和手機(jī)立即綁定

java基礎(chǔ)第二季,噠噠租車系統(tǒng)

標(biāo)簽:
Java

测试类(main)

package com.imooc.rentcar;

import java.util.Scanner;

public class test01 {

    public static void main(String[] args) {
        // TODO Auto-generated method stub
        Scanner in = new Scanner(System.in);
        int number;
        Car[] car =new Car[7];
        Car[] rentcar;
        System.out.println("欢迎使用哒哒租车系统:您是否要租车? 1是0否");
        System.out.println();
        if(in.nextInt()==1){
            System.out.println("您可租车的类型及价目表:\n"+
        "序号\t汽车名称\t租金\t容量");

            car[1]=new LoadPersonCar("奥迪A4",500,4);
            car[2]=new LoadPersonCar("马自达6",400,4);
            car[3]=new PickUp("皮卡雪6",450,4,2);
            car[4]=new LoadPersonCar("金龙",800,20);
            car[5]=new LoadThingCar("松花江",400,4);
            car[6]=new LoadThingCar("依维柯",1000,20);
            for(int i=1;i<=car.length-1;i++){
                if(car[i].PersonNum==0)
                System.out.println(i+"\t"+car[i].name+"\t"+car[i].price+"\t"+"载物"+car[i].ThingNum);
                else if(car[i].ThingNum==0)
                    System.out.println(i+"\t"+car[i].name+"\t"+car[i].price+"\t"+"载人"+car[i].PersonNum);    
                else
                    System.out.println(i+"\t"+car[i].name+"\t"+car[i].price+"\t"+"载人"+car[i].PersonNum+"载物"+car[i].ThingNum);
            }
            System.out.println("请输入您要租车数量:");
            number=in.nextInt();
            rentcar=new Car[number];
            for(int i=1;i<=number;i++){
                System.out.println("请输入第"+i+"辆的序号");
                int a =in.nextInt();
                rentcar[i-1]=car[a];
            }
            System.out.println("请输入租车天数");
            int  b=in.nextInt();
            System.out.println();
            System.out.println("您的账单:");
            int TotalPeopleSum=0;
            int TotaThingSum=0;
            int TotalPrice=0;
            for(Car mycar:rentcar){
                System.out.println(mycar.name);
                TotalPeopleSum+=mycar.PersonNum;
                TotaThingSum+=mycar.ThingNum;
                TotalPrice+=mycar.price;
            }
            System.out.println("总载客:"+TotalPeopleSum+",总载物"+TotaThingSum+",总价格"+TotalPrice*b);

        }

    }

}

车的父类

package com.imooc.rentcar;

public class Car {
    String name;
    int price;
    int PersonNum;
    int ThingNum;
    public Car(String name,int price){
        this.name=name;
        this.price=price;
    }

}

载人车

package com.imooc.rentcar;

public class LoadPersonCar extends Car {

    public LoadPersonCar(String name, int price) {
        super(name, price);
        // TODO Auto-generated constructor stub
    }
    public LoadPersonCar(String name,int price,int PersonNum) {
        // TODO Auto-generated constructor stub
        this(name, price);
        this.PersonNum=PersonNum;
    }

}

载物车

package com.imooc.rentcar;

public class LoadThingCar extends Car {

    public LoadThingCar(String name, int price) {
        super(name, price);
        // TODO Auto-generated constructor stub
    }

    public LoadThingCar(String name,int price,int ThingNum) {
        // TODO Auto-generated constructor stub
        this(name, price);
        this.ThingNum=ThingNum;
    }

}

皮卡

package com.imooc.rentcar;

public class PickUp extends Car {

    public PickUp(String name, int price) {
        super(name, price);
        // TODO Auto-generated constructor stub
    }

    public PickUp(String name,int price,int PersonNum,int ThingNum) {
        // TODO Auto-generated constructor stub
        this(name, price);
        this.PersonNum=PersonNum;
        this.ThingNum=ThingNum;
    }

}

运行结果

图片描述

點(diǎn)擊查看更多內(nèi)容
4人點(diǎn)贊

若覺得本文不錯(cuò),就分享一下吧!

評論

作者其他優(yōu)質(zhì)文章

正在加載中
感謝您的支持,我會繼續(xù)努力的~
掃碼打賞,你說多少就多少
贊賞金額會直接到老師賬戶
支付方式
打開微信掃一掃,即可進(jìn)行掃碼打賞哦
今天注冊有機(jī)會得

100積分直接送

付費(fèi)專欄免費(fèi)學(xué)

大額優(yōu)惠券免費(fèi)領(lǐng)

立即參與 放棄機(jī)會
微信客服

購課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學(xué)習(xí)伙伴

公眾號

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號

舉報(bào)

0/150
提交
取消