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

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

噠噠租車(chē)系統(tǒng)(Java入門(mén)第二季最后作業(yè))

標(biāo)簽:
Java

父类:定义车

package com.imooc;

public class Car {
      private String name;//车的名字
      private int carNum;//车的编号
      private int price;//车的价格
      private int carrying;//载货量
      private int seatload;//载客量
    public String getName() {
        return name;
    }
    public void setName(String name) {
        this.name = name;
    }
    public int getCarNum() {
        return carNum;
    }
    public void setCarNum(int carNum) {
        this.carNum = carNum;
    }
    public int getPrice() {
        return price;
    }
    public void setPrice(int price) {
        this.price = price;
    }
    public int getCarrying() {
        return carrying;
    }
    public void setCarrying(int carrying) {
        this.carrying = carrying;
    }
    public int getSeatload() {
        return seatload;
    }
    public void setSeatload(int seatload) {
        this.seatload = seatload;
    }

}

子类:定义客车

package com.imooc;

public class keche extends Car {
        public keche(int carNum,String name,int price,int seatload){
            super.setCarNum(carNum);
            super.setName(name);
            super.setPrice(price);
            super.setSeatload(seatload);
        }
}

子类:定义卡车

package com.imooc;

public class kache extends Car {
        public kache(int carNum,String name,int price,int carrying){
        super.setCarNum(carNum);
        super.setName(name);
        super.setPrice(price);
        super.setSeatload(carrying);
    }
}

子类:定义皮卡

package com.imooc;

public class pcar extends Car {
        public pcar(int carNum,String name,int price,int carrying,int seatload){
        super.setCarNum(carNum);
        super.setName(name);
        super.setPrice(price);
        super.setCarrying(carrying);
        super.setSeatload(seatload);
    }
}

调用方法:

package com.imooc;

import java.util.Scanner;

public class dadazuche {

    /**
     * @param args
     */
    public static void main(String[] args) {
        // TODO Auto-generated method stub
        int s0=0;
        Car[] carFormat = {new keche(1,"奥迪A4",500,4),new keche(2,"马自达6",400,4),
                new pcar(3,"皮卡雪6",450,4,4),new keche(4,"金龙",800,20),
                new kache(5,"松花江",400,4),new kache(6,"依维柯",1000,20)};//车辆信息
        int sum;//车辆总辆
        System.out.println("欢迎使用哒哒租车系统:");
        System.out.println("您是否要租车:1是 0否");
        Scanner s = new Scanner(System.in);
        s0 = s.nextInt();
        int i,j;
        if (s0 == 0) 
        { 
            System.out.println("感谢使用"); 
        }
        if (s0 == 1)
        {   
            System.out.printf("序号\t汽车名称\t租金\t容量\t车型总量\n");
            for(i=0;i<6;i++)
            {   
                if(i<2){
                sum=500;    
                System.out.println(carFormat[i].getCarNum() + ".\t" + carFormat[i].getName() + "\t" + carFormat[i].getPrice() + "元/天\t" + "载人:" + carFormat[i].getSeatload() + "人\t" + sum ); 
                }
                if(i==2){
                sum =500;
                //System.out.println(carFormat[1].getCarNum() + ".\t" + carFormat[1].getName() + "\t" + carFormat[1].getPrice() + "元/天\t" + "载人:" + carFormat[1].getSeatload() + "人\t" + 500); 
                //System.out.println(carFormat[2].getCarNum() + ".\t" + carFormat[2].getName() + "\t" + carFormat[2].getPrice() + "元/天\t" + "载人:" + carFormat[2].getSeatload() + "人\t" + 500); 
                System.out.println(carFormat[i].getCarNum() + ".\t" + carFormat[i].getName() + "\t" + carFormat[i].getPrice() + "元/天\t" + "载人:" + carFormat[i].getSeatload() + "人\t " + "载货:" + carFormat[i].getCarrying() + "吨\t" + 500); 
                }
                if(i==3){
                    sum=500;    
                    System.out.println(carFormat[i].getCarNum() + ".\t" + carFormat[i].getName() + "\t" + carFormat[i].getPrice() + "元/天\t" + "载人:" + carFormat[i].getSeatload() + "人\t" + sum ); 
                    }
                if(i>3){
                sum =1000;
                System.out.println(carFormat[i].getCarNum() + ".\t" + carFormat[i].getName() + "\t" + carFormat[i].getPrice() + "元/天\t" + "载货:" + carFormat[i].getCarrying() + "吨\t" + sum); 
                //System.out.println(carFormat[5].getCarNum() + ".\t" + carFormat[5].getName() + "\t" + carFormat[5].getPrice() + "元/天\t" + "载货:" + carFormat[5].getCarrying() + "吨\t" + sum);
                }
            }
            System.out.println("请输入您要租汽车的数量:");
            int sn = s.nextInt();
            int a[] = new int[sn];//选择汽车的信息保存数组
            if(sn>6){
                System.out.println("输入的数量大于已有数量。");
            }
            if(sn<=6){
            for (j=0;j<sn;j++){
            System.out.println("请输入第"+(j+1)+"辆车的序号");
            Scanner s1 = new Scanner(System.in);
            a[j] = s1.nextInt();
            }
            System.out.println("请输入租车天数:");
            int d = s.nextInt();
            int cusNum =0;//载人数
            int bagNum =0;//载货数
            int sumPrice =0; //总价格
            System.out.println("您的账单:");
            //***********************************************************************
            System.out.println("****可载人的车有:");

                for(int aj=0;aj<sn;aj++){
                    if(a[aj]== 1|| a[aj] == 2|| a[aj] == 4 ){
                cusNum += carFormat[a[aj]-1].getSeatload();
                System.out.print(carFormat[a[aj]-1].getName() + "\t");
                }
                }   
                System.out.println("共载人:"+ cusNum + "人");
            //**************************************************************************
            System.out.println("****可载货的车有:");
            for(int lj=0;lj<sn;lj++){
                if(a[lj]== 3|| a[lj] == 5|| a[lj] == 6 ){
            bagNum += carFormat[a[lj]-1].getCarrying();
            System.out.print(carFormat[a[lj]-1].getName() + "\t");
            }
            }   
            System.out.println("共载货:"+ bagNum + "吨");
            System.out.print("****租车总价格:");
            for(int bj=0;bj<sn;bj++){
                sumPrice += carFormat[bj].getPrice()*d; 
            }
            System.out.print(sumPrice);
            }
            }

        }

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

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

評(píng)論

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

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

100積分直接送

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

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

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

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

幫助反饋 APP下載

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

公眾號(hào)

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

舉報(bào)

0/150
提交
取消