Esempio n. 1
0
  public boolean addNewCaptain() {
    boolean check = false;
    try {
      view.displayPrintMessages("enterfirstname");
      String n1 = view.getInput();
      view.displayPrintMessages("enterlastname");
      String n2 = view.getInput();

      memHandler.addMember(n1, n2);
      check = true;
    } catch (Exception e) {
    }
    return check;
  }
Esempio n. 2
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;
 }
Esempio n. 3
0
 public boolean deleteCaptain() {
   boolean b = 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");
         return deleteCaptain();
       }
     }
     memHandler.deleteMember(mem);
     b = true;
   } catch (Exception e) {
   }
   return b;
 }
Esempio n. 4
0
  public boolean changeCaptain() {
    boolean b = 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("nosuchcaptain");
        }
      }
      view.displayPrintMessages("enternewfirstname");
      String n1 = view.getInput();
      view.displayPrintMessages("enternewlastname");
      String n2 = view.getInput();

      memHandler.changeMember(mem, n1, n2);
      b = true;
    } catch (Exception e) {
    }
    return b;
  }
Esempio n. 5
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;
  }
Esempio n. 6
0
  public boolean commandControll() {
    while (true) {
      view.displayheader();
      String cmd = view.getInput();

      if (cmd.equals(AddNewCaptain)) {
        boolean b = addNewCaptain();
        if (b == true) {
          view.displayPrintMessages("cptaddcnfrm");
        } else {
          view.displayPrintMessages("cptaddfail");
        }
      } else if (cmd.equals(AddNewShip)) {
        boolean b = addNewShip();
        if (b == true) {
          view.displayPrintMessages("shipaddcnfrm");
        } else {
          view.displayPrintMessages("shipaddfail");
        }
      } else if (cmd.equals(ChangeCaptain)) {
        boolean b = changeCaptain();
        if (b == true) {
          view.displayPrintMessages("captainchanged");
        } else {
          view.displayPrintMessages("captainchangefail");
        }
      } else if (cmd.equals(ChangeShip)) {
        boolean b = changeShip();
        if (b == true) {
          view.displayPrintMessages("shipchanged");
        } else {
          view.displayPrintMessages("shipchangedfail");
        }
      } else if (cmd.equals(DeleteCaptain)) {
        boolean b = deleteCaptain();
        if (b == true) {
          view.displayPrintMessages("deletecaptain");
        } else {
          view.displayPrintMessages("deletecaptainfail");
        }
      } else if (cmd.equals(DeleteShip)) {
        boolean b = deleteShip();
        if (b == true) {
          view.displayPrintMessages("shipdeleted");
        } else {
          view.displayPrintMessages("shipdeletedfail");
        }
      } else if (cmd.equals(exit)) {
        return false;
      } else {
        view.displayPrintMessages("invalid");
      }
    }
  }
Esempio n. 7
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;
  }