我怎么做的这么简陋 好多开关没有 该怎么加点好呢
public class Car { private String name; private String color; private int zuo; private int monry; private int t; private int code; public Car() { } public Car(int code,String name, String color, int zuo, int monry, int t) { setName(name); setCode(code); setZuo(zuo); setColor(color); setT(t); setMonry(monry); } public String getName() { return name; } public void setName(String name) { this.name = name; } public String getColor() { return color; } public void setColor(String color) { this.color = color; } public int getZuo() { return zuo; } public void setZuo(int zuo) { this.zuo = zuo; } public int getT() { return t; } public void setT(int t) { this.t = t; } public int getCode() { return code; } public void setCode(int code) { this.code = code; } public int getMonry() { return monry; } @Override public String toString() { return code+" "+name+" "+color+" "+zuo+" "+monry+" "+t; } public void setMonry(int monry) { this.monry = monry; } public void mycar(){ System.out.println(code+" "+name+" "+color+" "+zuo+" "+monry+" "+t); } }
---------------------------------------------------------------------------------------------------------------------------------------------------
import java.util.ArrayList; import java.util.Scanner; public class Car1 { public static void main(String[] args) { ArrayList<Car> list = new ArrayList<>(); System.out.println("序号--品 牌 ----颜色----座位数----价格----载重"); list =pree(); for (int i = 0; i < list.size(); i++) { System.out.println(list.get(i)); } Scanner sc = new Scanner(System.in); System.out.print("请输入第一台要租用的车型编号:"); int put0 = sc.nextInt(); System.out.print("请输入数量:"); int put1 = sc.nextInt(); System.out.print("请输入天数:"); int put2 = sc.nextInt(); System.out.print("请输入第二台要租用的车型编号:"); int put3 = sc.nextInt(); System.out.print("请输入数量:"); int put4 = sc.nextInt(); System.out.print("请输入天数:"); int put5 = sc.nextInt(); System.out.println("您的租车清单:"); System.out.println(list.get(put0-1)+" 数量:"+put1+" 天数:"+put2+"天"); System.out.println(list.get(put3-1)+" 数量:"+put4+" 天数:"+put5+"天"); System.out.println("总金额:"+ ((list.get(put0-1).getMonry())*put1*put2+list.get(put3-1).getMonry()*put4*put5)); } public static ArrayList<Car> pree(){ ArrayList<Car> list = new ArrayList<>(); list.add(new Car(1, "奔驰AMG", "红色", 5, 100, 0)); list.add(new Car(2, "宝马BWM", "白色", 5, 200, 0)); list.add(new Car(3, "腾风TGP", "蓝色", 1, 300, 0)); list.add(new Car(4, "华为HUV", "银色", 5, 400, 0)); list.add(new Car(4, "东风FUR", "红色", 3, 500, 100)); list.add(new Car(4, "长城SUV", "绿色", 5, 600, 2)); return list; } }