看了你们的代码发现,我的代码不能直视了~!
不能直视啊~!~!~!
package com.imooc; import java.util.Scanner; public class Initail { public static void main(String[] args) { // TODO Auto-generated method stub final int y=1; final int n=0; Vehicle car = new Vehicle(); Scanner input = new Scanner(System.in); System.out.println("请问您是否需要租车"+"\n"+"是按:"+y+"否按:"+n); int one = input.nextInt(); if (one == 1) { System.out.println("欢迎来到答答租车系统"+"\n"+"下面是您可租车的类型及价目表"); car.show(); int two = input.nextInt(); car.nums(two); int three = input.nextInt(); car.setDays(three); car.table(); }else if (one ==n) { System.out.println("退出答答租车系统!"); }else{ System.out.println("输入信息出错,系统自动退出!"); } } }
看了一下自己的代码,简直是,什么鬼~!
package com.imooc; import java.util.Scanner; public class Vehicle { public int sum;//总金额 public int sum2;//总人数 public int sum3;//总载货量 private int days;//总天数 public static int price ;//单价 public static int burden;//单辆车载货量 public static int seat;//单辆车载人数 public static String name; public static int[] burdens = {2,4,20}; public static int[] seats = {4,20}; public static String[] names={"奥迪A4 ","马自达6","皮卡雪6","金龙 ","松花江 ","依维柯 "}; public static int[] prices={500,400,450,400,800,1000}; public String[] capacity = {"载人:4人","载人:4人","载人:4人载货:2吨","载人:20人","载货:4吨","载货:20吨"}; Scanner input = new Scanner(System.in); public void show(){ System.out.println("序号 汽车类型 租金 容量"); for(int i=0;i<names.length;i++){ System.out.println((i+1)+". "+names[i]+" "+prices[i]+"元/天 "+capacity[i]); } System.out.println("请问您要组多少量车"); } public void nums(int nums){ for(int i=1;i<=nums;i++){ System.out.println("请输入第"+i+"辆车序号"); int two = input.nextInt(); if(two<=4 &&two!=3){ Salooncar.num(two); sum = sum + Salooncar.price; sum2 = sum2 + Salooncar.seat; }else if(two == 3){ Pickup.num(two); sum = sum + Pickup.price; sum2 = sum2 + Salooncar.seat; sum3 = sum3 + Wagon.burden; }else{ Wagon.num(two); sum = sum + Wagon.price; sum3 = sum3 + Wagon.burden; } } System.out.println("请问您要租多少天 "); } public int getDays() { return days; } public void setDays(int days) { this.days = days; } public void table(){ System.out.println("***您的账单***"); //载人 System.out.println("***可载人的车有:"); System.out.println("最多载人数量: "+sum2); //载货 System.out.println("***载货的车有:"); System.out.println("最多载货数重量: "+sum3); sum = sum*days; System.out.println("***租车总价:"+sum+"元"); } }
乱七八糟
package com.imooc; public class Salooncar extends Vehicle { public static void num(int num){ switch (num) { case 1:{ price = prices[num-1]; seat = seats[0]; } break; case 2:{ price = prices[num-1]; seat = seats[0]; } break; case 4:{ price = prices[num-1]; seat = seats[1]; } break; } } }
我还是再把第二季再学一遍好了Orz
package com.imooc; public class Pickup extends Vehicle{ public static void num(int num){ switch (num) { case 3:{ price = prices[num-1]; seat = seats[0]; burden = burdens[0]; } break; } } }
Orz我都不知道自己在写什么了!
package com.imooc; public class Wagon extends Vehicle { public int lc; public static void num(int num){ switch (num) { case 5:{ price = prices[num-1]; burden = burdens[1]; } break; case 6:{ price = prices[num-1]; burden = burdens[2]; } break; } } public static void names(int lc){ switch (lc) { case 5:{ name = names[lc-1]; } break; case 6:{ name = names[lc-1]; } break; } } }
总结:这段代码简直丧心病狂!Orz,早知道就不去看什么参考的内容了!搞得我一直在想怎么把参考内容弄出来~!