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

為了賬號安全,請及時綁定郵箱和手機(jī)立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

跪求大神解答

跪求大神解答

qq_82年的彬鍋鍋_03446807 2016-06-25 18:19:33
package com.chen1;?import java.util.Scanner;?public class Demo2 {? ? ? ? ?? ? public static void main(String[] args) {? ? //創(chuàng)建可租車列表? ? Car[] carsForRent={new PassengerCar("奧迪A4",500,4),new PassengerCar("馬自達(dá)6",400,4),? ? new PassengerCar("金龍",800,20),new Pickup("皮卡雪",450,2,4),? ? new Trunk("松花江",400,4),new Trunk("大阿肥",1000,20)};? ? System.out.println("歡迎使用達(dá)達(dá)租車系統(tǒng)");? ? System.out.println("您是否需要租車:1 是 \t其他任意鍵 否");? //獲取并保存輸入的值(一或者其他任意鍵)? ? Scanner scan=new Scanner(System.in);? ?String input=scan.next();? //判斷是否進(jìn)入租車系統(tǒng)? ?if(input.equals("1")){ ? System.out.println("你可租車類型及價(jià)目表"); ? System.out.println("序號\t汽車名稱\t租金 ? ? ? ? ? ? ? ? \t ? 容量");? int i=0;? for(Car currentCar:carsForRent){ //用instancreof判斷是否屬于汽車子類 ?if(currentCar instanceof PassengerCar){ ?i++; ?System.out.println(""+i+"\t"+currentCar.getName()+"\t"+currentCar.getRent()+"元/天\t"+((PassengerCar)currentCar).getpeopleCapacity()+"人\t" ? );} ?if(currentCar instanceof Trunk){ ?i++; ?System.out.println(""+i+"\t"+currentCar.getName()+"\t"+currentCar.getRent()+"元/天\t"+((Trunk)currentCar).getcargoCapacity()+"噸\t");} ?if(currentCar instanceof Pickup){ ?i++; ?System.out.println(""+i+"\t"+currentCar.getName()+"\t"+currentCar.getRent()+"元/天\t"+((Pickup)currentCar).getCargoCapacity()+"噸\t" ? +((Pickup)currentCar).getPeopleCapacity()+"人\t");}? }??? System.out.println("請輸入您要租車的數(shù)量:");? //獲取并保存輸入的值(租車的數(shù)量)? Scanner inputnum=new Scanner(System.in);?int number=inputnum.nextInt();// 輸入每輛租車的序號for(int j=1;j<=number;j++){System.out.println("請輸入第"+j+"臺車的序號:");Scanner inputnum1=new Scanner(System.in);int number1=inputnum1.nextInt();}//輸入租車天數(shù)System.out.println("請輸入租車天數(shù):");Scanner inputnum2=new Scanner(System.in);int days=inputnum2.nextInt();//租車賬單System.out.println("您的賬單:");double total=0;Car car=new PassengerCar();total=car.getRent()*days;? System.out.println("***租車總價(jià)格:"+total);?}? ?? ?else { ? System.out.println("您已退出達(dá)達(dá)租車系統(tǒng)!");? ?}??? ? ? ? ? ??? ? }? ? }?//汽車類class Car{ //成員屬性String name;?double carCapacity;?double rent;?//獲取名字public String getName() { return name;}//設(shè)定名字public void setName(String name) { this.name = name;}//獲取汽車容量public double getCarCapacity() { return carCapacity;}//設(shè)定汽車容量public void setCarCapacity(double carCapacity) { this.carCapacity = carCapacity;}//獲取租金public double getRent() { return rent;}//設(shè)定租金public void setRent(double rent) { this.rent = rent;} }//子類卡車?yán)^承父類汽車class Trunk extends Car{ //卡車容量屬性封裝? ? private double cargoCapacity;// ?構(gòu)造方法 ?,自動調(diào)用構(gòu)造方法完成對新對象的初始化 public Trunk(String name,double rent,double cargoCapacity){ this.name=name; this.rent=rent; this.cargoCapacity=cargoCapacity; } //獲取卡車載貨容量 public double getcargoCapacity(){ return cargoCapacity; } }//子類客車?yán)^承父類汽車class PassengerCar extends Car{ //客車載入容量屬性封裝 private double peopleCapacity; //構(gòu)造方法,完成對新對象的屬性初始化public PassengerCar(String name,double rent,double peopleCapacity){ this.name=name; this.rent=rent; this.peopleCapacity=peopleCapacity; }?//獲取客車載入的容量public double getpeopleCapacity(){ return 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 double getPeopleCapacity() { return peopleCapacity; } }
查看完整描述

2 回答

?
qq_82年的彬鍋鍋_03446807

TA貢獻(xiàn)4條經(jīng)驗(yàn) 獲得超0個贊

http://img1.sycdn.imooc.com//576e5b3700013b2e12590448.jpg就后面這個寫不出來

查看完整回答
反對 回復(fù) 2016-06-25
?
qq_82年的彬鍋鍋_03446807

TA貢獻(xiàn)4條經(jīng)驗(yàn) 獲得超0個贊

http://img1.sycdn.imooc.com//576e5aff0001e76a18701028.jpg效果是這個

查看完整回答
反對 回復(fù) 2016-06-25
  • 2 回答
  • 0 關(guān)注
  • 1561 瀏覽

添加回答

舉報(bào)

0/150
提交
取消
微信客服

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

幫助反饋 APP下載

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

公眾號

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