Ejemplo n.º 1
0
 public void processBuyPart(Part p) throws DataException {
   boolean check = partCtrl.buyPart(p);
   if (!check) {
     System.out.println(
         "You don't have the required level/resources to buy this part! Please come back later.");
   } else {
     System.out.println("Purchase successfully!");
   }
 }
Ejemplo n.º 2
0
 public void displayPartMenu(String type) throws DataException {
   ArrayList<Part> list = partCtrl.retrieveAvailablePartsByType(type);
   System.out.println();
   System.out.println("== BattleStations :: Le Part :: " + type + " ==");
   for (int i = 0; i < list.size(); i++) {
     Part p = list.get(i);
     System.out.println((i + 1) + ". " + p.getName() + " (min: L" + p.getLvlReq() + ")");
   }
   System.out.print("[R]eturn to main | Enter number > ");
 }
Ejemplo n.º 3
0
 public void readPartOption(String type) throws DataException {
   String input = null;
   do {
     displayPartMenu(type);
     input = sc.next();
     sc.nextLine();
     if (input.length() != 1 && input.length() != 2) {
       System.out.println("Invalid input!");
     } else if (input.equals("R")) {
     } else {
       try {
         int choice = Integer.parseInt(input);
         Part p = partCtrl.retrievePart(type, choice); // clone part here
         readBuyOption(p);
       } catch (InputMismatchException e) {
         System.out.println("Invalid input! Please try again!");
       }
     }
   } while (!input.equals("R"));
 }