谁能帮我解决case1和case3,谢谢

时间:2019-05-04 20:17:04

标签: java

导入java.util.Scanner;

class Main {   静态最终整数MAXCUSTOMERS = 4;   静态最终int MAXTRUCKS = 3;

静态字符串卡车[] = {“丰田”,“日产”,“雷克萨斯”}; //卡车名称的数组   static int custRents [] = new int [MAXCUSTOMERS]; //卡车租赁阵列   静态字符串custNames [] =新的String [MAXCUSTOMERS]; //客户名称数组   int lastCustId = 0;   公共静态void main(String [] args){     int truckNum,customerNum,选项;     字符串truckName;

option = 0;
Scanner in = new Scanner(System.in);
initializeRenting();

while (option != 7)
{
  System.out.println("");
  System.out.println("********************* Truck Rent **********");
  System.out.println("1: Register a new customer");
  System.out.println("2: To rent a truck");
  System.out.println("3: Return a truck");
  System.out.println("4: check if a truck is available in the store");
  System.out.println("5: Check if store owns a truck ");
  System.out.println("6: Print the name of a customer from his ID ");
  System.out.println("7: EXIT");
  option = in.nextInt();
  switch(option) {
    case 1:


      break;
    case 2: 
      System.out.println("Customer Number:");
      truckNum = in.nextInt();
      System.out.println("truck Number:");
      customerNum = in.nextInt();

      if (!rentTruck(customerNum, truckNum))
          System.out.println("Error Renting atruck");
      break;
    case 3:


      break;
    case 4: 
      System.out.println("truck Number:");
      truckNum = in.nextInt();
      if (isTruckAvailable(truckNum))
        System.out.println("truck: " + trucks[truckNum] + ", is available for renting");
      else
        System.out.println("truck: " + trucks[truckNum] + ", is not available for renting.");
      break;
    case 5: 
     System.out.println("truck Name:");
      truckName = in.next();
      System.out.println(truckName);
      if (doesStoreHaveTruck(truckName))
        System.out.println("The store owns this truck");
      else
        System.out.println("The store does not own this truck");
    case 6:
        break;
    }//switch
  }//while loop
  System.out.println("Thank you and good buy");
}

public static void initializeRenting(){     为(int i = 0; i

公共静态布尔rentTruck(int cust,int truckNum){     if((cust> = MAXCUSTOMERS)||(cust <0))//检查数组边界       返回false;     其他{       custRents [cust] = truckNum;       返回true;     }   }

公共静态布尔值isTruckAvailable(int Nissan){     为(int i = 0; i

公共静态布尔布尔didStoreHaveTruck(String truckName){     为(int i = 0; i

return false;

}

}

0 个答案:

没有答案