lab 5
diff --git a/src/sample/ArtRico.java b/src/sample/ArtRico.java
index 2ed17b0..120958d 100644
--- a/src/sample/ArtRico.java
+++ b/src/sample/ArtRico.java
@@ -35,7 +35,8 @@
for (int i = 0; i < MENU_SIZE; i++) {
mainMenuButtons[i] = new Button();
mainMenuButtons[i].setLayoutX(SCENE_WIDTH / 2 - BUTTON_WIDTH / 2);
- mainMenuButtons[i].setLayoutY(i * (BUTTON_HEIGHT + BUTTON_BORDER) + BUTTON_BORDER);
+ mainMenuButtons[i].setLayoutY(i * (BUTTON_HEIGHT + BUTTON_BORDER)
+ + BUTTON_BORDER);
mainMenuButtons[i].setPrefSize(BUTTON_WIDTH, BUTTON_HEIGHT);
menuRoot.getChildren().add(mainMenuButtons[i]);
}
@@ -52,7 +53,8 @@
for (int i = 0; i < NEW_GAME_MENU_SIZE; i++) {
newGameMenuButtons[i] = new Button();
newGameMenuButtons[i].setLayoutX(SCENE_WIDTH / 2 - BUTTON_WIDTH / 2);
- newGameMenuButtons[i].setLayoutY(i * (BUTTON_HEIGHT + BUTTON_BORDER) + BUTTON_BORDER);
+ newGameMenuButtons[i].setLayoutY(i * (BUTTON_HEIGHT + BUTTON_BORDER)
+ + BUTTON_BORDER);
newGameMenuButtons[i].setPrefSize(BUTTON_WIDTH, BUTTON_HEIGHT);
menuRoot.getChildren().add(newGameMenuButtons[i]);
}
@@ -88,7 +90,8 @@
});
scene = new Scene(menuRoot);
- scene.getStylesheets().add(ArtRico.class.getResource("style.css").toExternalForm());
+ scene.getStylesheets().add(ArtRico.class.getResource("style.css")
+ .toExternalForm());
primaryStage.setScene(scene);
primaryStage.show();
}
diff --git a/src/sample/Constants.java b/src/sample/Constants.java
index 7960fba..f2d1c05 100644
--- a/src/sample/Constants.java
+++ b/src/sample/Constants.java
@@ -38,6 +38,7 @@
int BUTTON_BORDER = 20;
int MENU_SIZE = 5;
int NEW_GAME_MENU_SIZE = 4;
- String[] TOP_LABEL_CONTENT = {"REPLAY", "MODE", "PLAYED", "MOVED LEFT", "MOVED RIGHT"};
+ String[] TOP_LABEL_CONTENT = {"REPLAY", "MODE", "PLAYED", "MOVED LEFT"
+ , "MOVED RIGHT"};
String RESOURSE_FOLDER = "Resource\\";
}
diff --git a/src/sample/FileWorker.java b/src/sample/FileWorker.java
deleted file mode 100644
index 7394719..0000000
--- a/src/sample/FileWorker.java
+++ /dev/null
@@ -1,34 +0,0 @@
-package sample;
-
-import java.io.*;
-
-public class FileWorker {
-
- public static void saveReplay(String fileName, String string) {
- File file = new File(fileName);
- try(FileWriter writer = new FileWriter(file, false)) {
- writer.write(string);
- writer.flush();
- }
- catch(IOException ex) {
- System.out.println(ex.getMessage());
- }
- }
-
- public static String loadReplay(String fileName) {
- File file = new File(fileName);
- String replay = "";
- try(FileReader reader = new FileReader(file))
- {
- char[] buffer = new char[(int)file.length()];
- reader.read(buffer);
- replay = new String(buffer);
- }
- catch(IOException ex){
- System.out.println(ex.getMessage());
- }
- finally {
- return replay;
- }
- }
-}
diff --git a/src/sample/Game.java b/src/sample/Game.java
index 20675dc..b0bf266 100644
--- a/src/sample/Game.java
+++ b/src/sample/Game.java
@@ -41,7 +41,8 @@
} catch (InterruptedException e) {
}
scene = client.scene;
- scene.getStylesheets().add(Game.class.getResource("style.css").toExternalForm());
+ scene.getStylesheets().add(Game.class.getResource("style.css")
+ .toExternalForm());
gameStage.setScene(scene);
gameStage.show();
}
@@ -66,7 +67,8 @@
menuRoot.getChildren().add(gridPane);
addLabels(gridPane);
scene = new Scene(menuRoot);
- scene.getStylesheets().add(Game.class.getResource("style.css").toExternalForm());
+ scene.getStylesheets().add(Game.class.getResource("style.css")
+ .toExternalForm());
gridPane.setOnMouseClicked(e -> {
int fileNumber = ((int) e.getY()) / GRID_LABEL_HEIGHT - 1;
@@ -75,7 +77,8 @@
replayFile = RESOURSE_FOLDER + fileNames[fileNumber];
startGame();
} else if (fileNumber == -1) {
- ReplayInfo.sortBy = (int) e.getX() * 5 / (SCENE_WIDTH - GRID_INDENTS * 2);
+ ReplayInfo.sortBy = (int) e.getX() * 5 / (SCENE_WIDTH -
+ GRID_INDENTS * 2);
replays.sort(ReplayInfo::compareTo);
addLabels(gridPane);
}
@@ -126,13 +129,15 @@
gridPane.add(gameTimeLabel, 2, i + 1);
Label leftMovingTimeLabel = new Label();
- leftMovingTimeLabel.setText(Integer.toString(replays.get(i).getLeftMovingTime()));
+ leftMovingTimeLabel.setText(Integer.toString(replays.get(i)
+ .getLeftMovingTime()));
leftMovingTimeLabel.setPrefWidth((SCENE_WIDTH - GRID_INDENTS * 2) / 5);
leftMovingTimeLabel.setPrefHeight(GRID_LABEL_HEIGHT);
gridPane.add(leftMovingTimeLabel, 3, i + 1);
Label rightMovingTimeLabel = new Label();
- rightMovingTimeLabel.setText(Integer.toString(replays.get(i).getRightMovingTime()));
+ rightMovingTimeLabel.setText(Integer.toString(replays.get(i)
+ .getRightMovingTime()));
rightMovingTimeLabel.setPrefWidth((SCENE_WIDTH - GRID_INDENTS * 2) / 5);
rightMovingTimeLabel.setPrefHeight(GRID_LABEL_HEIGHT);
gridPane.add(rightMovingTimeLabel, 4, i + 1);
diff --git a/src/sample/ReplayInfo.java b/src/sample/ReplayInfo.java
index db587d2..5f5af32 100644
--- a/src/sample/ReplayInfo.java
+++ b/src/sample/ReplayInfo.java
@@ -44,7 +44,8 @@
int result = 0;
switch (sortBy) {
case 0:
- result = Integer.compare(new Integer(replayName), new Integer(o.replayName));
+ result = Integer.compare(new Integer(replayName),
+ new Integer(o.replayName));
break;
case 1:
result = replayMode.compareTo(o.replayMode);
diff --git a/src/sample/Server.java b/src/sample/Server.java
index 895176c..be82018 100644
--- a/src/sample/Server.java
+++ b/src/sample/Server.java
@@ -84,7 +84,8 @@
PLAYER_POS_Y, PLAYER_WIDTH_EASY, PLAYER_HEIGHT,
STROKE_WIDTH, Color.ORANGERED, Color.BEIGE,
WALL_WIDTH, SCENE_WIDTH - WALL_WIDTH, PLAYER_SPEED_EASY);
- ball = new Ball(SCENE_WIDTH / 2 - BALL_SIZE / 2, PLAYER_POS_Y - BALL_SIZE,
+ ball = new Ball(SCENE_WIDTH / 2 - BALL_SIZE / 2, PLAYER_POS_Y
+ - BALL_SIZE,
BALL_SIZE, BALL_SIZE, STROKE_WIDTH, Color.ORANGERED,
Color.BEIGE, WALL_WIDTH, SCENE_WIDTH - WALL_WIDTH,
TOP_HEIGHT, SCENE_HEIGHT, BALL_SPEED_EASY);
@@ -95,7 +96,8 @@
PLAYER_POS_Y, PLAYER_WIDTH_MEDIUM,
PLAYER_HEIGHT, STROKE_WIDTH, Color.ORANGERED, Color.BEIGE,
WALL_WIDTH, SCENE_WIDTH - WALL_WIDTH, PLAYER_SPEED_MEDIUM);
- ball = new Ball(SCENE_WIDTH / 2 - BALL_SIZE / 2, PLAYER_POS_Y - BALL_SIZE,
+ ball = new Ball(SCENE_WIDTH / 2 - BALL_SIZE / 2, PLAYER_POS_Y
+ - BALL_SIZE,
BALL_SIZE, BALL_SIZE, STROKE_WIDTH, Color.ORANGERED,
Color.BEIGE, WALL_WIDTH, SCENE_WIDTH - WALL_WIDTH,
TOP_HEIGHT, SCENE_HEIGHT, BALL_SPEED_MEDIUM);
@@ -176,7 +178,8 @@
}
client.resetBricks();
createBricks(BRICKS_IN_RAW, BRICKS_IN_COLOMN, BRICKS_WIDTH, BRICKS_HEIGHT);
- player.setTranslateX(SCENE_WIDTH / 2 - player.getWidth() / 2 + STROKE_WIDTH / 2);
+ player.setTranslateX(SCENE_WIDTH / 2 - player.getWidth() / 2
+ + STROKE_WIDTH / 2);
player.setTranslateY(PLAYER_POS_Y);
ball.setTranslateX(SCENE_WIDTH / 2 - BALL_SIZE / 2);
ball.setTranslateY(PLAYER_POS_Y - BALL_SIZE);