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

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

學(xué)過C語言,這個小項目我也寫了,但是習(xí)慣性用函數(shù)的方式去寫,不習(xí)慣用接口和抽象類。。。。

package 達(dá)達(dá)租車;


public class Vehicle {

?String []str={"奧迪A4","馬自達(dá)6","皮卡雪6","金龍 ","松花江","依維柯 ?"};

?int []p={500,400,450,800,400,1000};

?

? ? ?void information(){

? ? System.out.println("你可租車的類型及其價格表:");

? ? System.out.println("序號 ? ? ? ? ? ?汽車名稱 ? ? ? ? ? ? ? ?租金 ? ? ? ? ? ? ? ? ? ? ? ?容量 ? ");

? ? System.out.println("1. ? ?奧迪A4 ? ? 500元/天 ? ? ? ? ? 載人:4人 ? ? ?");

? ? System.out.println("2. ? ?馬自達(dá)6 ? ? 400元/天 ? ? ? ? ? 載人:4人 ? ? ?");

? ? System.out.println("3. ? ?皮卡雪6 ? ? 450元/天 ? ? ? ? ? 載人:4人 ? 載貨:2噸 ? ");

? ? System.out.println("4. ? ?金龍 ? ? ? ? ? 800元/天 ? ? ? ? ? 載人:20人 ? ? ?");

? ? System.out.println("5. ? ?松花江 ? ? ? ?400元/天 ? ? ? ? ? 載貨:4噸 ? ? ");

? ? System.out.println("6. ? ?依維柯 ? ? ? ?1000元/天 ? ? ? ?載貨:20噸 ? ? ?");

? ? ?}

? ? ?

? ? ?void showcar1(int a,int b[]){

? ? System.out.println("***可載人的車有:");

? ? ?

? ? for(int i=0;i<a;i++){

? ? if(b[i]<5)

? ? System.out.print(str[b[i]-1]+" ? "); ? ? ?

? ? }

? ? ?

? ? ?}

? ? ?

? ? ?void showcar2(int a,int b[]){

? ? System.out.println("\n***可載貨的車有:");

? ? for(int i=0;i<a;i++){

? ? if(b[i]>5||b[i]==3)

? ? System.out.print(str[b[i]-1]+" ? ");

? ?

? ? }

? ? ?}

? ? ? ? ?

? ? ?

? ? ?

? ? ?void bill(int a,int d,int b[]){ ? ?

? ? int m=0;

? ? for(int i=0;i<a;i++){

? ? ? ? m=m+(p[b[i]-1]*d);

? ? }

? ? System.out.println("\n***租車總價格:"+m);

? ? ?

? ??

? ? ?}

}

package 達(dá)達(dá)租車;


import java.util.*;

public class Carrental {


public static void main(String[] args) {

// TODO Auto-generated method stub

? ? ? ? Vehicle v=new Vehicle();

? ? ? ??

? ? ? ? Scanner reader=new Scanner(System.in);

? ? ? ? System.out.println("歡迎使用達(dá)達(dá)租車系統(tǒng):");

? ? ? ? System.out.println("你是否要租車:1是 ? 0否");

? ? ? ??

? ? ? ? int s=reader.nextInt();

? ? ? ? if(s==1){

? ? ? ? ? ?v.information();

? ? ? ? ? ?System.out.println("請輸入您要租汽車的數(shù)量:");

? ? ? ? ? ?int a=reader.nextInt();

? ? ? ? ? ?int b[]=new int[a];

? ? ? ? ? ?for(int i=0;i<a;i++){

? ? ? ? ? System.out.println("請輸入第"+(i+1)+"輛車的序號:");

? ? ? ? ? b[i]=reader.nextInt();

? ? ? ? ? ?}

? ? ? ? ? ?System.out.println("請輸入租車天數(shù):");

? ? ? ? ? ?int d=reader.nextInt();

? ? ? ? ? ?System.out.println("您的賬單:");

? ? ? ? ? ?v.showcar1(a,b);

? ? ? ? ? ?v.showcar2(a,b); ??

? ? ? ? ? ?v.bill(a,d,b);

? ? ? ? }

? ? ? ? else

? ? ? ? System.exit(0);

}


}


正在回答

1 回答

那就要習(xí)慣用面向?qū)ο笏枷?,函?shù)方式的代碼太多太亂,太復(fù)雜,結(jié)構(gòu)非常難懂,不便于管理。

0 回復(fù) 有任何疑惑可以回復(fù)我~

舉報

0/150
提交
取消

學(xué)過C語言,這個小項目我也寫了,但是習(xí)慣性用函數(shù)的方式去寫,不習(xí)慣用接口和抽象類。。。。

我要回答 關(guān)注問題
微信客服

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

幫助反饋 APP下載

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

公眾號

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