Exemple #1
0
  /**
   * Rendering method for the HighScoreBoard.
   *
   * @param gameContainer used by the program.
   * @param stateBasedGame being played at the moment.
   * @param graphics used by the game.
   * @throws SlickException
   */
  @Override
  public void render(GameContainer gameContainer, StateBasedGame stateBasedGame, Graphics graphics)
      throws SlickException {
    gameContainer.setPaused(tPause);
    if (!tPause) {
      tBackground.draw(0, 0, gameContainer.getWidth(), gameContainer.getHeight());

      graphics.setColor(Color.white);
      graphics.drawString("HIGH SCORE BOARD", 600, 100);
      graphics.drawString("Press Enter to return to menu", 550, 150);

      if (tMain.getGame() == null) {
        tHighScoreManager = new HighScoreManager();
      } else {
        tHighScoreManager = tMain.getGame().getHighScoreManager();
      }

      ArrayList<Score> list = tHighScoreManager.getScores();
      int x = 400;
      int y = 300;
      int j = 1;

      for (Score aList : list) {
        graphics.drawString(
            j + ". " + aList.getPlayer() + ": " + Integer.toString(aList.getScore()) + "\n", x, y);
        y = y + 25;
        j = j + 1;
      }
    }
  }
  private void populateAdminHeaders() {

    HashMap<String, String> adminMap = Main.getAdminDetails();
    adminAgencyName.setText(adminMap.get("name"));
    adminMobileLabel.setText(adminMap.get("mobile"));
    adminAddrLabel.setText(adminMap.get("addr"));
  }
  private boolean productExistsInCategory(String name, String category) {
    try {

      Connection con = Main.dbConnection;
      if (!con.isValid(0)) {
        con = Main.reconnect();
      }
      String query =
          "select count(*) from products where lower(name)=? and lower(bill_category)=? and product_id<>?";
      PreparedStatement stmt = con.prepareStatement(query);
      stmt.setString(1, name.toLowerCase());
      stmt.setString(2, category.toLowerCase());
      stmt.setLong(3, productRow.getProductId());
      ResultSet rs = stmt.executeQuery();
      if (rs.next()) {
        if (rs.getInt(1) > 0) return true;
      }
    } catch (SQLException e) {

      Main._logger.debug("Error :", e);
      e.printStackTrace();
    } catch (Exception e) {

      Main._logger.debug("Error :", e);
      e.printStackTrace();
    }
    return false;
  }
  public void populateBillCategoryValues() {
    try {

      Connection con = Main.dbConnection;
      if (!con.isValid(0)) {
        con = Main.reconnect();
      }
      billCategoryValues = FXCollections.observableArrayList();
      PreparedStatement stmt =
          con.prepareStatement(
              "select distinct bill_category from point_name order by bill_category");
      ResultSet rs = stmt.executeQuery();
      while (rs.next()) {
        if (billCategoryValues != null && !billCategoryValues.contains(rs.getString(1)))
          billCategoryValues.add(rs.getString(1).toLowerCase());
      }
      billCategoryTF.setItems(billCategoryValues);
      new AutoCompleteComboBoxListener<>(billCategoryTF);
    } catch (SQLException e) {

      Main._logger.debug("Error :", e);
      e.printStackTrace();
    } catch (Exception e) {

      Main._logger.debug("Error :", e);
      e.printStackTrace();
    }
  }
  public void populateProdTypeValues() {
    try {

      Connection con = Main.dbConnection;
      if (!con.isValid(0)) {
        con = Main.reconnect();
      }
      productTypeValues.clear();
      PreparedStatement stmt =
          con.prepareStatement(
              "select value, code, seq, lov_lookup_id from lov_lookup where code='PRODUCT_TYPE' order by seq");
      ResultSet rs = stmt.executeQuery();
      while (rs.next()) {
        productTypeValues.add(rs.getString(1));
      }
      typeTF.getItems().addAll(productTypeValues);
    } catch (SQLException e) {

      Main._logger.debug("Error :", e);
      e.printStackTrace();
    } catch (Exception e) {

      Main._logger.debug("Error :", e);
      e.printStackTrace();
    }
  }
Exemple #6
0
  /**
   * Initialize variables for the test process.
   *
   * @throws Exception possible Exception.
   */
  @Before
  public void setUp() throws Exception {
    testWon = new Won(1);
    testWon.tMain = mockedGame;

    when(mockedGame.getGame()).thenReturn(new Game(0, 0, mockedLogger, 1));
  }
Exemple #7
0
 /**
  * Method to check whether a key is released.
  *
  * @param key integer value for a key.
  * @param c character value for a key.
  */
 public void keyReleased(int key, char c) {
   switch (key) {
     default:
       break;
     case Input.KEY_ENTER:
       tMain.enterState(0, new FadeOutTransition(Color.black), new FadeInTransition(Color.black));
   }
 }
 /** Resets initBoard, all panes with Circles, and text */
 public void reset() {
   Random randoInt = Main.randoInt;
   ArrayList<pieceType> initSolution =
       Board.generateSolution(
           randoInt.nextInt(4), randoInt.nextInt(4), randoInt.nextInt(4), randoInt.nextInt(4));
   Main.initBoard = new Board(initSolution);
   guesses.getChildren().clear();
   inputBox.getChildren().clear();
   winLose.setText("");
   guessSet.setDisable(false);
   Main.allGuesses.clear();
   Main.generateAllGuesses(Main.allGuesses);
 }
  @FXML
  void updateAdminDetails(ActionEvent event) {
    try {
      TextField mobileNum = new TextField();
      TextField agencyName = new TextField();
      TextField addr = new TextField();

      Connection con = Main.dbConnection;
      if (!con.isValid(0)) {
        con = Main.reconnect();
      }
      String query =
          "select company_name,company_mobile,company_addr from admin_login where username ='******' ";
      PreparedStatement stmt = con.prepareStatement(query);
      //			stmt.setString(1, HawkerLoginController.loggedInHawker.getPointName());
      ResultSet rs = stmt.executeQuery();
      if (rs.next()) {
        agencyName.setText(rs.getString(1));
        mobileNum.setText(rs.getString(2));
        addr.setText(rs.getString(3));
      }
      rs.close();
      stmt.close();

      Dialog<ButtonType> deleteWarning = new Dialog<ButtonType>();
      deleteWarning.setTitle("Update Admin Details");
      deleteWarning.setHeaderText("Update admin details below.");
      ButtonType saveButtonType = new ButtonType("Save", ButtonData.OK_DONE);
      deleteWarning.getDialogPane().getButtonTypes().addAll(saveButtonType, ButtonType.CANCEL);

      GridPane grid = new GridPane();
      grid.setHgap(10);
      grid.setVgap(10);
      grid.setPadding(new Insets(20, 150, 10, 10));

      grid.add(new Label("Agency Name"), 0, 0);
      grid.add(new Label("Mobile"), 0, 1);
      grid.add(new Label("Address"), 0, 2);
      grid.add(agencyName, 1, 1);
      grid.add(mobileNum, 1, 0);
      grid.add(addr, 1, 2);
      deleteWarning.getDialogPane().setContent(grid);
      Optional<ButtonType> result = deleteWarning.showAndWait();
      if (result.isPresent() && result.get() == saveButtonType) {
        PreparedStatement updateStmt =
            con.prepareStatement(
                "update admin_login set company_name=?, company_mobile=?, company_addr=?");
        updateStmt.setString(1, agencyName.getText());
        updateStmt.setString(2, mobileNum.getText());
        updateStmt.setString(3, addr.getText());
        updateStmt.executeUpdate();
      }
    } catch (SQLException e) {

      Main._logger.debug("Error :", e);
      e.printStackTrace();
    } catch (Exception e) {

      Main._logger.debug("Error :", e);
      e.printStackTrace();
    }
  }
  @FXML
  private void changePasswordClicked(ActionEvent evt) {
    TextInputDialog changePwdDialog = new TextInputDialog();
    changePwdDialog.setTitle("Change password");
    changePwdDialog.setHeaderText(
        "Please enter the new password. \nPassword must be atleast 5 characters long.");
    // changePwdDialog.getDialogPane().getButtonTypes().addAll(ButtonType.OK,
    // ButtonType.CANCEL);
    final Button btOk = (Button) changePwdDialog.getDialogPane().lookupButton(ButtonType.OK);
    btOk.addEventFilter(
        ActionEvent.ACTION,
        event -> {
          if (changePwdDialog.getEditor().getText().isEmpty()
              || changePwdDialog.getEditor().getText().length() < 5) {
            Notifications.create()
                .title("Empty password")
                .text(
                    "Password cannot be left empty and must be more than 5 characters. Try again.")
                .hideAfter(Duration.seconds(5))
                .showError();
            event.consume();
          }
        });
    Optional<String> result = changePwdDialog.showAndWait();
    if (result.isPresent()) {
      try {

        Connection con = Main.dbConnection;
        if (!con.isValid(0)) {
          con = Main.reconnect();
        }
        String deleteString = "update admin_login set password =? where username='******'";
        PreparedStatement deleteStmt = con.prepareStatement(deleteString);
        deleteStmt.setString(1, changePwdDialog.getEditor().getText());

        deleteStmt.executeUpdate();
        con.commit();

        Notifications.create()
            .title("Password updated")
            .text("Password was successfully updated. Please login again!")
            .hideAfter(Duration.seconds(5))
            .showInformation();
        logoutClicked(new ActionEvent());
      } catch (SQLException e) {

        Main._logger.debug("Error :", e);
        e.printStackTrace();
        Notifications.create()
            .hideAfter(Duration.seconds(5))
            .title("Delete failed")
            .text("Delete request of hawker bill has failed")
            .showError();
      } catch (IOException e) {

        Main._logger.debug("Error :", e);
        e.printStackTrace();
      } catch (Exception e) {

        Main._logger.debug("Error :", e);
        e.printStackTrace();
      }
    }
  }
 @FXML
 public void cambiarEscena2() {
   main.cambiarEscena2();
 }