Skip to content
Snippets Groups Projects
Commit 39fc1e77 authored by Lars-Johan Larsen's avatar Lars-Johan Larsen :speech_balloon:
Browse files

trying to fix tags

parent 5e9ecc5f
No related branches found
No related tags found
No related merge requests found
package edu.ntnu.stud;
import edu.ntnu.stud.menubuilder.UserInterface;
public class Main {
public static void main(String[] args) {
UserInterface blarg = new UserInterface();
blarg.init();
blarg.start();
}
}
package edu.ntnu.stud.menubuilder;
import edu.ntnu.stud.menubuilder.menu.Menu;
import edu.ntnu.stud.menubuilder.trainz.Station;
/** .
*
*/
public class TrainDispatchSystem {
public class UserInterface {
private Menu mainMenu;
private Station station;
private static Menu buildSubmenu(String menuName, Station myStation) {
Menu tmpMenu = new Menu(menuName);
//logic to make MenuItems for the Menu goes here
return tmpMenu;
}
/** Innitialize the main menu and all menu functionality.
*
*/
public void init() {
station = new Station();
mainMenu = new Menu("Example Main Menu");
mainMenu.newEntry("Option 1", () -> System.out.println("Execute Option 1"));
mainMenu.newEntry("Option 2", () -> System.out.println("Execute Option 2"));
mainMenu.newEntry("Option 3", () -> System.out.println("Execute Option 3"));
mainMenu.newEntry("Submenu 4", () -> UserInterface.buildSubmenu("Option 4", station));
}
/** Display the menu and start running menu functionality.
*
*/
public void start() {
mainMenu.displayMenu(false);
}
}
......@@ -77,7 +77,7 @@ class Departure {
private void verifySetDelay(Duration duration) {
if (this.originalDepartureTime.plus(duration).isBefore(this.originalDepartureTime)) {
throw new IllegalArgumentException(
"Substracting this delay duration makes the departure time LocalTime less than original departure.");
"The new delay duration makes the departure before originalDeparture.");
}
if (this.originalDepartureTime.plus(duration).isAfter(LocalTime.MAX)) {
throw new IllegalArgumentException(
......@@ -95,11 +95,6 @@ class Departure {
throw new IllegalArgumentException(
"Adding this delay duration exceeds the maximum value for the departure time LocalTime");
}
if (duration.isNegative()) {
throw new IllegalArgumentException(
"Cannot add a negative delay duration, use subDelay() with a possitive duration"
);
}
if (duration.isZero()) {
throw new IllegalArgumentException(
"Cannot add a zero duration delay, this is pointless."
......@@ -107,28 +102,6 @@ class Departure {
}
}
/** Throws an error if invalid input is given to subDelay().
*
* @param duration A Duration representing a delay.
* @throws IllegalArgumentException For illegal durations.
*/
private void verifySubDelay(Duration duration) {
if (this.originalDepartureTime.minus(duration).isBefore(LocalTime.of(0, 0))) {
throw new IllegalArgumentException(
"Substracting this delay duration makes the departure time LocalTime less than zero.");
}
if (duration.isNegative()) {
throw new IllegalArgumentException(
"Cannot subtract a negative delay duration, use addDelay() with a possitive duration"
);
}
if (duration.isZero()) {
throw new IllegalArgumentException(
"Cannot subtract a zero duration delay, this is pointless."
);
}
}
/** Sets a delay from this departure's departureTime(LocalTime).
*
* @param duration A Duration to add to the LocalTime of the departure.
......@@ -151,18 +124,6 @@ class Departure {
this.delay = this.delay.plus(duration);
}
/** Substracts a Duration from this departure's departuretime(LocalTime).
*
* @param duration A Duration to subtract to the LocalTime of the departure.
* @throws ArithmeticException - if numeric overflow occurs.
* @throws DateTimeException - if the subtraction cannot be made.
* @throws IllegalArgumentException - if the Duration would result in an invalid departure time.
*/
public void subDelay(Duration duration) {
verifySubDelay(duration);
this.delay = this.delay.minus(duration);
}
/** Gets the delay for this departure.
*
* @return a Duration representing a delay.
......
package edu.ntnu.stud.menubuilder.trainz;
/**
* Station
*/
public class Station {
}
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment