Skip to content

Commit

Permalink
made public methods private
Browse files Browse the repository at this point in the history
  • Loading branch information
filiphuhta committed Jul 4, 2021
1 parent 133fde4 commit 3a6d17e
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 6 deletions.
4 changes: 1 addition & 3 deletions src/App.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@
public class App {
public static void main(String[] args) throws Exception {
Simulator simulator = new Simulator();
var room = simulator.setRoomSize();
var car = simulator.setStartDest();
simulator.runSimulation(car, room);
simulator.startSimulator();
}

}
17 changes: 14 additions & 3 deletions src/Simulator.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,24 @@

public class Simulator {

/**
* Get the user input about the room size and the starting
* destionation of the car.
*
*/
public void startSimulator() throws IOException {
var room = setRoomSize();
var car = setStartDest();
runSimulation(car, room);
}

/**
* Ask user for the room size which should be writed in the format (4 6).
*
* If it was wrong format it will ask the user again until the user have writed
* the correct input.
*/
public Room setRoomSize() throws IOException {
private Room setRoomSize() throws IOException {
BufferedReader standardInput = new BufferedReader(new InputStreamReader(System.in));
String wrongInput = "The input must be written with two integers separated with a space. Example: 4 10";
boolean isCorrect = false;
Expand Down Expand Up @@ -49,7 +60,7 @@ public Room setRoomSize() throws IOException {
* If it was wrong format it will ask the user again until the user have writed
* the correct input.
*/
public Car setStartDest() throws IOException {
private Car setStartDest() throws IOException {
BufferedReader standardInput = new BufferedReader(new InputStreamReader(System.in));
String wrongInput = "This input must be two integers and one letter separated with spaces. The letter can be N, S, W or E.";
boolean isCorrect = false;
Expand Down Expand Up @@ -84,7 +95,7 @@ public Car setStartDest() throws IOException {
* When simulation is done it checks if the car has crashed in to the wall or
* not.
*/
public void runSimulation(Car car, Room room) throws IOException {
private void runSimulation(Car car, Room room) throws IOException {
BufferedReader standardInput = new BufferedReader(new InputStreamReader(System.in));
System.out.print("Input car simulation commands in series. Available commands are F, B, L or R.");
String simulationInput = standardInput.readLine();
Expand Down

0 comments on commit 3a6d17e

Please sign in to comment.