国产精品天干天干,亚洲毛片在线,日韩gay小鲜肉啪啪18禁,女同Gay自慰喷水

歡迎光臨散文網(wǎng) 會(huì)員登陸 & 注冊

Java oop:租車系統(tǒng)詳細(xì)解析和顏色分層,幫你更易看懂結(jié)構(gòu)

2020-02-21 11:46 作者:詩書畫唱  | 我要投稿

package b;


import java.util.Scanner;


public class Text {


public static void main(String[] args) {


che xiaohuoche = new huoche(1, "小貨車", 30, 0, 3);


che dahuoche = new huoche(2, "大貨車", 50, 0, 5);


che xiaokeche = new keche(3, "小客車", 40, 4, 0);


che dakeche = new keche(4, "大客車", 80, 10, 0);


che xiaopika = new pika(5, "小皮車", 60, 2, 4);


che dapika = new pika(6, "大皮車", 100, 4, 8);


che[] c = new che[6];


c[0] = xiaohuoche;

c[1] = dahuoche;

c[2] = xiaokeche;


c[3] = dakeche;

c[4] = xiaopika;

c[5] = dapika;


yonghu yh = new yonghu();


che[] c_zuche = null;


while (true) {


System.out.println("---------神舟租車系統(tǒng)-----------");


System.out.println("請輸入你的操作:1.登錄? 2.注冊? 3.跳出系統(tǒng)");


Scanner s = new Scanner(System.in);


int num = s.nextInt();


if (num == 1) {


System.out.println("----執(zhí)行登錄操作----");


System.out.println("請輸入用戶名:");


String uname = s.next();


System.out.println("請輸入你的密碼");


String pwd = s.next();


if (uname.equals(yh.uname) && pwd.equals(yh.pwd)) {


System.out.println("登錄成功!");


break;


} else {


System.out.println("登錄失敗");


}


} else if (num == 2) {


System.out.println("----執(zhí)行注冊操作----");


System.out.println("請輸入用戶名:");


String uname = s.next();


System.out.println("請輸入你的密碼");


String pwd = s.next();


System.out.println("請輸入你的姓名");


String name = s.next();


yh.uname = uname;


yh.pwd = pwd;


yh.name = name;


System.out.println("注冊成功!");


} else if (num == 3) {


System.exit(0);


}


}


// 租車操作


while (true) {


System.out.println("歡迎," + yh.name + "請選擇你的操作:");


System.out

.println("1.查看車輛列表? 2.進(jìn)行租車? 3.查看我的租車總價(jià)格,總載人量,總載物量 4.跳出系統(tǒng)");


Scanner s1 = new Scanner(System.in);


int num = s1.nextInt();


if (num == 1) {


for (che i : c) {/* 相當(dāng)于for(int i=0;i<c.length;i++) */


i.jieshao();


}


} else if (num == 2) {


System.out.println("請輸入你要租的車輛數(shù)");


int num1 = s1.nextInt();


c_zuche = new che[num1];


for (int i = 0; i < num1; i++) {


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


int bianhao = s1.nextInt();


switch (bianhao) {


case 1:


c_zuche[i] = xiaohuoche;

break;


case 2:


c_zuche[i] = dahuoche;

break;


case 3:


c_zuche[i] = xiaokeche;

break;


case 4:


c_zuche[i] = dakeche;

break;


case 5:


c_zuche[i] = xiaopika;

break;


case 6:


c_zuche[i] = dapika;

break;


}


}


System.out.println("租車成功!");


} else if (num == 3) {


if (c_zuche == null) {


System.out.println("你還沒有進(jìn)行租車呢!");


} else {


int zongjiage = 0;


int zongzairenliang = 0;


int zongzaiwuliang = 0;


for (che i : c_zuche) {


i.jieshao();


zongjiage += i.jiage;


zongzairenliang += i.zaikeliang;


zongzaiwuliang += i.zaiwuliang;


}


System.out.println("總價(jià)格" + zongjiage + "總載人量" +


zongzairenliang + "總載物量" + zongzaiwuliang);


}


} else {


System.exit(0);/* 終止系統(tǒng),不可為break,break是跳出循環(huán) */


}


}


}


}


class yonghu {


String uname;


String pwd;


String name;


}


abstract class che {


int bianhao;


String name;


int jiage;


int zaikeliang;


int zaiwuliang;


public che(int bianhao, String name, int jiage, int zaikeliang,int zaiwuliang) {


this.bianhao = bianhao;


this.name = name;


this.jiage = jiage;


this.zaikeliang = zaikeliang;


this.zaiwuliang = zaiwuliang;


}


abstract void jieshao();


}


class huoche extends che {


public huoche(int bianhao, String name, int jiage,


int zaikeliang, int zaiwuliang) {


super(bianhao, name, jiage, zaikeliang, zaiwuliang);


}


void jieshao() {


System.out.println("編號" + this.bianhao + "\t名稱" + this.name +


"\t價(jià)格" + this.jiage + "\t載物量" + this.zaiwuliang);


}


}


class keche extends che {


public keche(int bianhao, String name, int jiage, int zaikeliang,


int zaiwuliang) {


super(bianhao, name, jiage, zaikeliang, zaiwuliang);


}


void jieshao() {


System.out.println("編號" + this.bianhao + "\t名稱" +


this.name + "\t價(jià)格" + this.jiage + "\t載人量" + this.zaikeliang);


}


}


class pika extends che {


public pika(int bianhao, String name, int jiage, int zaikeliang,


int zaiwuliang) {


super(bianhao, name, jiage, zaikeliang, zaiwuliang);


}


void jieshao() {


System.out.println("編號" + this.bianhao + "\t名稱" +


this.name + "\t價(jià)格" + this.jiage + "\t載人量" + this.zaikeliang + "載物量" +


this.zaiwuliang);


}


}



Java oop:租車系統(tǒng)詳細(xì)解析和顏色分層,幫你更易看懂結(jié)構(gòu)的評論 (共 條)

分享到微博請遵守國家法律
蕉岭县| 曲水县| 奇台县| 凉城县| 沂南县| 黄山市| 荣昌县| 桐城市| 微博| 新兴县| 平南县| 宜都市| 永康市| 田阳县| 房产| 墨玉县| 新野县| 阿尔山市| 称多县| 获嘉县| 尚义县| 屏南县| 台北县| 平舆县| 新源县| 南部县| 夏津县| 屏边| 饶平县| 辽中县| 芜湖县| 长寿区| 融水| 东台市| 邓州市| 阜宁县| 涿鹿县| 和林格尔县| 葫芦岛市| 广昌县| 海阳市|