新手java求指导

System.out.println("欢迎使用达达租车系统");

    System.out.println("您是否要租车:是1   否0");

    Scanner input = new Scanner (System.in);

    int i=input.nextInt();

    if (i==1){

    System.out.println("您可租车的类型及其价目表:");

    System.out.println("序号"+"\t"+"汽车名称"+"\t"+"租金"+"\t"+"容量");

    }else{

    System.out.println("欢迎您再次光临达达租车系统");

    }

    int j;

    for (j=0;j<6;j++){

    if (automobileMessenge[j] instanceof Car){

    System.out.println(automobileMessenge[j].num+"\t"+automobileMessenge[j].name+"\t"

    +automobileMessenge[j].rent+"元/天"+"\t"+"载人:"+((project7.Car) automobileMessenge[j]).getPeopleCount()+"人");

    }

    if (automobileMessenge[j] instanceof Trunk){

    System.out.println(automobileMessenge[j].num+"\t"+automobileMessenge[j].name+"\t"

        +automobileMessenge[j].rent+"元/天"+"\t"+"载货:"+((project7.Trunk) automobileMessenge[j]).getThingCount()+"吨");

    }

    if (automobileMessenge[j] instanceof PickUp){

    System.out.println(automobileMessenge[j].num+"\t"+automobileMessenge[j].name+"\t"+

    automobileMessenge[j].rent+"元/天"+"\t"+"载人:"+((project7.PickUp) automobileMessenge[j]).getPeopleCount()

        +"载货:"+((project7.PickUp) automobileMessenge[j]).getThingCount()+"吨");

    }

    }

    System.out.println("请输入您要租车的数量");

    int carTotal=input.nextInt();

    int choice []=new int[carTotal];

    for(j=0;j<carTotal;j++){

    System.out.println("请输入第"+""+(j+1)+"辆车的序号");

    choice [j]=input.nextInt();

      }

现在想把choice数组循环并判断是能载人的还是载货的车 并输出出来 实在没思路了






慕粉1471134825
浏览 1290回答 1
1回答

Nirva_Troy

http://www.imooc.com/article/17523看看这个,为什么不用类的继承,定义两个子类,货车和小汽车,覆写下父类的方法就行了
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

Java