Skip to content
This repository has been archived by the owner on Jun 25, 2023. It is now read-only.

Commit

Permalink
Clean up scanners
Browse files Browse the repository at this point in the history
Co-Authored-By: cedricjansen <[email protected]>
  • Loading branch information
lukasgabriel and cedricjansen committed Jun 27, 2020
1 parent 161e161 commit 5ce3cfb
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 3 deletions.
3 changes: 2 additions & 1 deletion src/main/java/de/hspforzheim/items/FlightManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ private int getFlightInput(ArrayList<Flight> allFlights) {
scanner.next();
}
}

scanner.close();
return input;
}

Expand All @@ -239,6 +239,7 @@ private int getDishInput(ArrayList<Dish> dishes) {
scanner.next();
}
}
scanner.close();
return input;
}

Expand Down
1 change: 1 addition & 0 deletions src/main/java/de/hspforzheim/items/Manager.java
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ protected void delete(Object sender) {
System.out.println(DELETE_HEAD); // Print the head.
// If sender is instanceof Flightmanager and there are no flights to delete, return.
if(listIsEmpty(flights, dishes, sender)) {
scanner.close();
return;
};
// While user input is anything but IN, ID or X, loop.
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/de/hspforzheim/menues/Menu.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@

import de.hspforzheim.Eaf;
import de.hspforzheim.commands.MenuOperation;
import de.hspforzheim.commands.OperationType;
import java.util.Calendar;
import java.util.InputMismatchException;
import java.util.Scanner;
Expand Down Expand Up @@ -105,6 +104,7 @@ protected void userInput() {
userInput = -1;
scanner.next(); // ignore this input and clear stream for the next one.
}
scanner.close();
}


Expand Down
3 changes: 2 additions & 1 deletion src/main/java/items/FlightManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ private int getFlightInput(ArrayList<Flight> allFlights) {
scanner.next();
}
}

scanner.close();
return input;
}

Expand All @@ -239,6 +239,7 @@ private int getDishInput(ArrayList<Dish> dishes) {
scanner.next();
}
}
scanner.close();
return input;
}

Expand Down
1 change: 1 addition & 0 deletions src/main/java/items/Manager.java
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ protected void delete(Object sender) {
System.out.println(DELETE_HEAD); // Print the head.
// If sender is instanceof Flightmanager and there are no flights to delete, return.
if(listIsEmpty(flights, dishes, sender)) {
scanner.close();
return;
};
// While user input is anything but IN, ID or X, loop.
Expand Down

0 comments on commit 5ce3cfb

Please sign in to comment.