亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

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

代碼流程有問題,請大佬幫忙指點一下

package?com.exc;import?java.util.Scanner;public?class?DDRental?{	public?static?void?main(String[]?args)?{		int?money?=0;		Car[]?carForRentCars?=?{new?AutoCar("奧迪",?500,?4),?new?AutoCar("馬自達",?400,?4),?				new?AutoCar("金龍",?800,?20)?,new?Trunk("松花江",?400,?4),?				new?Trunk("依維柯",?1000,?20),?new?PickCar("皮卡",?450,?2,?4)};			System.out.println("歡迎使用噠噠租車系統~~~");		System.out.println("您是否要租車:1是???2否");		Scanner?sc?=?new?Scanner(System.in);				boolean?flag?=?true;		while?(flag)?{			int?rent?=?sc.nextInt();			switch?(rent)?{			case?1:				System.out.println("您可租車的類型及其價格表如下:");				System.out.println("序號\t汽車名稱\t租金\t\t容量");								for?(int?i?=?0;?i?<?carForRentCars.length;?i++)?{					if?(carForRentCars[i]?instanceof?AutoCar)?{						AutoCar?aCar?=?(AutoCar)?carForRentCars[i];						System.out.println((i+1)?+?"\t"?+?aCar.name?+"\t"?+?aCar.rent?+?"元/天\t\t載人:"?+?aCar.getPeopleCapacity()?+"人");					}?else?if?(carForRentCars[i]?instanceof?Trunk)?{						Trunk?trunk?=?(Trunk)?carForRentCars[i];						System.out.println((i+1)?+?"\t"?+?trunk.name?+"\t"?+?trunk.rent?+?"元/天\t\t載人:"?+?trunk.getCargoCapacity()?+"人");					}?else?if?(carForRentCars[i]?instanceof?PickCar)?{						PickCar?pCar?=?(PickCar)?carForRentCars[i];						System.out.println((i+1)?+?"\t"?+?pCar.name?+"\t"?+?pCar.rent?+?"元/天\t\t載人:"?+??pCar.getPeopleCapacity()?+?								"人???載貨:"+?pCar.getCargoCapacity()?+"噸");					}				}				flag?=?false;				break;			case?2:				System.out.println("感謝您的光臨,期待下次與您再見,祝您生活愉快!");				flag?=?false;				break;			default:				System.out.println("您好,您的輸入不正確。請根據提示正確輸入!");				break;			}		}				System.out.println("請輸入您要租車的數量:");		int?count?=?sc.nextInt();		for?(int?i?=?1;?i?<=?count;?i++)?{			System.out.println("請輸入第"?+?i?+"輛車的序號:");			int?id?=?sc.nextInt();			switch?(id)?{			case?1:				money?+=?carForRentCars[0].getRent();				break;			case?2:				money?+=?carForRentCars[1].getRent();				break;			case?3:				money?+=?carForRentCars[2].getRent();				break;			case?4:				money?+=?carForRentCars[3].getRent();				break;			case?5:				money?+=?carForRentCars[4].getRent();				break;			case?6:				money?+=?carForRentCars[5].getRent();				break;			default:				break;			}		}				System.out.println("請輸入租車天數:");		int?day?=?sc.nextInt();		System.out.println("您的帳單:"?+?day*money?+?"元!??!");	}}class?Car{	String?name;	int?rent;	public?Car()?{}		public?String?getName()?{		return?name;	}	public?void?setName(String?name)?{		this.name?=?name;	}	public?double?getRent()?{		return?rent;	}	public?void?setRent(int?rent)?{		this.rent?=?rent;	}		}class?AutoCar?extends?Car{	private?int?peopleCapacity;		public?AutoCar()?{}	public?AutoCar(String?name,?int?rent,?int?peopleCapacity)?{		this.name?=?name;		this.rent?=?rent;		this.peopleCapacity?=?peopleCapacity;	}	public?int?getPeopleCapacity()?{		return?peopleCapacity;	}	public?void?setPeopleCapacity(int?peopleCapacity)?{		this.peopleCapacity?=?peopleCapacity;	}	}class?Trunk?extends?Car{	private?int?cargoCapacity;		public?Trunk()?{}	public?Trunk(String?name,?int?rent,?int?cargoCapacity)?{		this.name?=?name;		this.rent?=?rent;		this.cargoCapacity?=?cargoCapacity;	}	public?int?getCargoCapacity()?{		return?cargoCapacity;	}	public?void?setCargoCapacity(int?cargoCapacity)?{		this.cargoCapacity?=?cargoCapacity;	}	}class?PickCar?extends?Car{	private?int?cargoCapacity;	private?int?peopleCapacity;		public?PickCar()?{}	public?PickCar(String?name,?int?rent,?int?cargoCapacity,?int?peopleCapacity)?{		this.name?=?name;		this.rent?=?rent;		this.cargoCapacity?=?cargoCapacity;		this.peopleCapacity?=?peopleCapacity;	}	public?int?getCargoCapacity()?{		return?cargoCapacity;	}	public?void?setCargoCapacity(int?cargoCapacity)?{		this.cargoCapacity?=?cargoCapacity;	}	public?int?getPeopleCapacity()?{		return?peopleCapacity;	}	public?void?setPeopleCapacity(int?peopleCapacity)?{		this.peopleCapacity?=?peopleCapacity;	}	}


正在回答

2 回答

看到我想給你一耳巴子 哈哈


0 回復 有任何疑惑可以回復我~

對不起各位,格式亂了,這個問題就當我沒發布過

1 回復 有任何疑惑可以回復我~

舉報

0/150
提交
取消

代碼流程有問題,請大佬幫忙指點一下

我要回答 關注問題
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號