为了账号安全,请及时绑定邮箱和手机立即绑定

我怎么做的这么简陋 好多开关没有 该怎么加点好呢

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;
    }
}


正在回答

1 回答

看来我不太适合学这东西 就TM这么点代码 愣是写了半天? 我感觉快放弃了

0 回复 有任何疑惑可以回复我~
#1

一生清贫怎敢入繁华

别轻言放弃,刚入门,接触一个全新的领域,谁都不可能立即就能得心应手,得在学习的过程中,不断实践,不断思考,才能学会,从小白到大神,没有轻松的,我也是小白啊,也在学习啊,也不会啊,也觉得难啊,可是干嘛要放弃呢?
2019-05-16 回复 有任何疑惑可以回复我~
#2

weixin_慕的地0154058 回复 一生清贫怎敢入繁华

一起加油
2019-05-18 回复 有任何疑惑可以回复我~

举报

0/150
提交
取消

我怎么做的这么简陋 好多开关没有 该怎么加点好呢

我要回答 关注问题
意见反馈 帮助中心 APP下载
官方微信