package carrentalcompany;public class saloon { //父类 方法类 private String pinpai; //品牌 private String chepai; //车牌 private String xinghao; //型号 private int money; //价格 private double sum; //总金额 public int getMoney() { return money; } public void setMoney(int money) { this.money = money; } public double getSum() { return sum; } public void setSum(double sum) { this.sum = sum; } public String getXinghao() { return xinghao; } public void setXinghao(String xinghao) { this.xinghao = xinghao; } public String getPinpai() { return pinpai; } public void setPinpai(String pinpai) { this.pinpai = pinpai; } public String getChepai() { return chepai; } public void setChepai(String chepai) { this.chepai = chepai; } void showinfo(){ System.out.println("品牌"+"\t\t车牌"+"\t\t型号"+"\t\t价格"); System.out.println(getPinpai()+"\t\t"+getChepai()+"\t\t"+getXinghao()+"\t\t"+getMoney()); }}
package carrentalcompany;public class coach { //添加车数 int money; int sum; saloon[] sal=new saloon[5]; public void cos(saloon salo){ for(int i=0;i
package carrentalcompany;import java.util.Scanner;public class TestCar { public static void main(String[] alg){ Scanner in=new Scanner(System.in); coach c=new coach(); boolean fale=true; while(fale){ System.out.println("欢迎来到租车公司!"); System.out.println("请输入要租车的天数:"); int tian=in.nextInt(); System.out.println("请输入你要租的汽车类型:1-轿车,2-客车,3-卡车,0-结束"); int x=in.nextInt(); if(x==1){//轿车 System.out.println("请输入要租的品牌:1-宝马,2-别克"); int b=in.nextInt(); if(b==1){//宝马 c.add(tian); c.showCoach(); }else if(b==2){ //别克 c. bie(tian); c.showCoach(); } }else if(x==2){//客车 System.out.println("请输入要租的品牌:1-金杯,2-金龙"); int b=in.nextInt(); if(b==1){ c.jin(tian); c.showCoach(); }else if(b==2){ c.lon(tian); c.showCoach(); } }else if(x==3){ //卡车 System.out.println("请输入要租的品牌:1-大型卡车,2-中型卡车"); int b=in.nextInt(); if(b==1){ c.ka(tian); c.showCoach(); }else if(b==2){ c.kas(tian); c.showCoach(); } } if(x==0){ fale=false; c.sums(); System.out.println("品牌"+"\t\t车牌"+"\t\t型号"+"\t\t价格"); } } }}