예제 #1
0
  public boolean addNewShip() {
    boolean check = false;
    try {
      view.displayPrintMessages("entercaptainid");
      String memID = view.getInput();
      Member mem = new Member();
      for (Member m : sql.getAllMembers()) {
        if (m.getMemberID().equals(memID)) {
          mem = m;
        } else {
          view.displayPrintMessages("nocushcaptain");
        }
      }
      view.displayPrintMessages("entershipname");
      String shipName = view.getInput();
      view.displayPrintMessages("entershipclass");
      String shipClass = view.getInput();
      view.displayPrintMessages("enterguncaliber");
      int shipGunCaliber = Integer.parseInt(view.getInput());
      view.displayPrintMessages("enternguns");
      int shipnguns = Integer.parseInt(view.getInput());
      view.displayPrintMessages("entershiplength");
      int shiplength = Integer.parseInt(view.getInput());

      shipHandler.addShip(mem, shipName, shipClass, shipGunCaliber, shipnguns, shiplength);
      check = true;
    } catch (Exception e) {
    }
    return check;
  }
예제 #2
0
  public boolean changeShip() {
    boolean b = false;
    try {
      view.displayPrintMessages("shipaccess");
      String sn = view.getInput();
      Ship ship = new Ship();
      for (Ship s : sql.getAllShips()) {
        if (s.getShipName().equals(sn)) {
          ship = s;
        }
      }
      view.displayPrintMessages("entershipname");
      String shipName = view.getInput();
      view.displayPrintMessages("entershipclass");
      String shipClass = view.getInput();
      view.displayPrintMessages("enterguncaliber");
      int shipGunCaliber = Integer.parseInt(view.getInput());
      view.displayPrintMessages("enternguns");
      int shipnguns = Integer.parseInt(view.getInput());
      view.displayPrintMessages("entershiplength");
      int shiplength = Integer.parseInt(view.getInput());

      shipHandler.changeShip(ship, shipName, shipClass, shipGunCaliber, shiplength, shipnguns);
      b = true;
    } catch (Exception e) {
    }
    return b;
  }
예제 #3
0
 public boolean deleteShip() {
   boolean b = false;
   try {
     view.displayPrintMessages("shipaccess");
     String sn = view.getInput();
     Ship ship = new Ship();
     for (Ship s : sql.getAllShips()) {
       if (s.getShipName().equals(sn)) {
         ship = s;
       } else {
         view.displayPrintMessages("nosuchship");
       }
     }
     shipHandler.deleteShip(ship);
     b = true;
   } catch (Exception e) {
   }
   return b;
 }