汽車租賃系統-java_第1頁
汽車租賃系統-java_第2頁
汽車租賃系統-java_第3頁
汽車租賃系統-java_第4頁
全文預覽已結束

下載本文檔

版權說明:本文檔由用戶提供并上傳,收益歸屬內容提供方,若內容存在侵權,請進行舉報或認領

文檔簡介

1、實現租車汽車租賃系統,不同車型日租金情況如表 7-1所示;車型及日期轎車客車車型別克Gl8寶馬750別克凱越二19 座>19座日租金(元 /天)7506005008001200編程實現計算不同車型不同天數的租賃費用。package zuche;public abstract class MotoVehicle privateStringno;privateStringbrand ;int 口 fee = 750,600,500,800,1200; public MotoVehicle() public MotoVehicle(String no,String brand ) this .

2、 no=no; this . brand =brand ;public String getNo() return no;public String getBrand() return brand ;public void setBrand(String brand ) this . brand =brand ;public void setNo(String no) this . no=no;public void printInfo() System. out .println( "* 汽車的信息*" +"n 汽車品牌"+this . brand +

3、"n 車牌號"+this . no); public abstract void calRent( int days);package zuche;public class Car extends MotoVehicle private String type ;/String type1= "別克凱越","寶馬730","別克凱越","中小客車(19座以 內)","大型客車(19座以上)"public Car() public Car(String no,String br

4、and ,String type ) super (no, brand );this . type =type ; )public String getType() return type ;)public void setType(String type ) this . type =type ;)public void printInfo() /super.printInfo();調用父類的構造方法,子類不能直接繼承父類的構造方法;System. out .println( "* 汽車的信息*" +"n 汽車品牌"+getBrand()+ "

5、;n 型 號"+this . type +"n 車牌號"+getNo();)public void calRent( int days ) int rent =0;if ("寶馬".equals(getBrand() rent =days *600; else if ("另1J克".equals(getBrand()&&'gl8" .equals( this . type ) rent =days *750; elserent =days *500;System. out .println(

6、 "你的租車費用為"+rent +"元");package zuche;public class Bus extendsMotoVehicle private int seatCount ; public Bus() public int getSeatCount() return seatCount ;public void setSeatCount( int seatCount ) this . seatCount =seatCount ; public void printInfo() System. out .println(''

7、* 汽車的信息*刈 +"n 車牌號"+getNo()+ "n 客車座位藪"+this . seatCount +"座");)public void calRent( int days) int rent =0;if ( seatCount <=19) rent =days *800; else rent =days *1200;System. out .println( "你的租車費用為"+rent +"元"); package zuche;import java.util.Scanner

8、;public class TestRent public static void main(String args ) Scanner input =new Scanner(System. in ); /int carType;String answer;int day =0;Car c=new Car();"*歡迎光臨西樹東花租車*");,、*,、 、Bus b=new Bus();System. out .println(System. out .println(int random =(int )(Math. random ()*89999+10000); /ran

9、dom()的取值范圍為0,1);do System. out .println("轎車請選:1" +"n 貨車請選:2");c.setNo("黑At" +random);if (input .nextInt()=1) System. out .println("請輸入汽車的品牌(1.寶馬、2.別克)");switch (input .nextInt() case 1:c.setBrand("寶馬");c.setType( "730");c. printInfo();Syste

10、m. out .println("請輸入租車天數");c.calRent( input .nextInt(); break ;case 2:System. out .println("請選擇別克車的類型:if (input .nextInt()=1) c.setBrand("別式");c.setType( "gl8");c. printInfo();System. out .println( "請輸入租車天數");c .calRent( input .nextInt(); else c.setBrand(

11、"別克");c.setType("凱越");c. printInfo();System. out .println( "請輸入租車天數");c .calRent( input .nextInt();else System. out .println( "請選擇客車的座位數: b.setNo("黑A" +random);switch ( input .nextInt() case 1: b.setSeatCount(17);b.printInfo();System. out .println( "請輸入租車天數");b.calRent( input .nextInt(); break ; case 2:b.setSeatCount(21);b.printInfo();System. out .println("請輸入租車天數");b.calRent( input .nextInt(); break ;System. out .println("是

溫馨提示

  • 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯系上傳者。文件的所有權益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網頁內容里面會有圖紙預覽,若沒有圖紙預覽就沒有圖紙。
  • 4. 未經權益所有人同意不得將文件中的內容挪作商業或盈利用途。
  • 5. 人人文庫網僅提供信息存儲空間,僅對用戶上傳內容的表現方式做保護處理,對用戶上傳分享的文檔內容本身不做任何修改或編輯,并不能對任何下載內容負責。
  • 6. 下載文件中如有侵權或不適當內容,請與我們聯系,我們立即糾正。
  • 7. 本站不保證下載資源的準確性、安全性和完整性, 同時也不承擔用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。

評論

0/150

提交評論