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

Update and clean up documentation a bit

parent 8ed24bfc
No related branches found
No related tags found
No related merge requests found
<mxfile host="Electron" modified="2023-11-27T09:27:40.582Z" agent="Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) draw.io/22.1.2 Chrome/114.0.5735.289 Electron/25.9.4 Safari/537.36" etag="-7CDhBWkfeZ3BCSrebN6" version="22.1.2" type="device">
<diagram id="C5RBs43oDa-KdzZeNtuy" name="Page-1">
<mxGraphModel dx="1036" dy="606" grid="1" gridSize="10" guides="1" tooltips="1" connect="1" arrows="1" fold="1" page="1" pageScale="1" pageWidth="827" pageHeight="1169" math="0" shadow="0">
<root>
<mxCell id="WIyWlLk6GJQsqaUBKTNV-0" />
<mxCell id="WIyWlLk6GJQsqaUBKTNV-1" parent="WIyWlLk6GJQsqaUBKTNV-0" />
<mxCell id="zkfFHV4jXpPFQw0GAbJ--0" value="TrainDispatchSystem" style="swimlane;fontStyle=2;align=center;verticalAlign=top;childLayout=stackLayout;horizontal=1;startSize=26;horizontalStack=0;resizeParent=1;resizeLast=0;collapsible=1;marginBottom=0;rounded=0;shadow=0;strokeWidth=1;" parent="WIyWlLk6GJQsqaUBKTNV-1" vertex="1">
<mxGeometry x="334" y="120" width="160" height="138" as="geometry">
<mxRectangle x="230" y="140" width="160" height="26" as="alternateBounds" />
</mxGeometry>
</mxCell>
<mxCell id="zkfFHV4jXpPFQw0GAbJ--1" value="Station" style="text;align=left;verticalAlign=top;spacingLeft=4;spacingRight=4;overflow=hidden;rotatable=0;points=[[0,0.5],[1,0.5]];portConstraint=eastwest;" parent="zkfFHV4jXpPFQw0GAbJ--0" vertex="1">
<mxGeometry y="26" width="160" height="26" as="geometry" />
</mxCell>
<mxCell id="zkfFHV4jXpPFQw0GAbJ--2" value="Menu" style="text;align=left;verticalAlign=top;spacingLeft=4;spacingRight=4;overflow=hidden;rotatable=0;points=[[0,0.5],[1,0.5]];portConstraint=eastwest;rounded=0;shadow=0;html=0;" parent="zkfFHV4jXpPFQw0GAbJ--0" vertex="1">
<mxGeometry y="52" width="160" height="26" as="geometry" />
</mxCell>
<mxCell id="zkfFHV4jXpPFQw0GAbJ--4" value="" style="line;html=1;strokeWidth=1;align=left;verticalAlign=middle;spacingTop=-1;spacingLeft=3;spacingRight=3;rotatable=0;labelPosition=right;points=[];portConstraint=eastwest;" parent="zkfFHV4jXpPFQw0GAbJ--0" vertex="1">
<mxGeometry y="78" width="160" height="8" as="geometry" />
</mxCell>
<mxCell id="A6uXA1JAniuv3VXLVRst-30" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;exitX=0.5;exitY=0;exitDx=0;exitDy=0;entryX=0;entryY=0.5;entryDx=0;entryDy=0;" parent="WIyWlLk6GJQsqaUBKTNV-1" source="zkfFHV4jXpPFQw0GAbJ--6" target="zkfFHV4jXpPFQw0GAbJ--2" edge="1">
<mxGeometry relative="1" as="geometry" />
</mxCell>
<mxCell id="zkfFHV4jXpPFQw0GAbJ--6" value="Menu" style="swimlane;fontStyle=0;align=center;verticalAlign=top;childLayout=stackLayout;horizontal=1;startSize=26;horizontalStack=0;resizeParent=1;resizeLast=0;collapsible=1;marginBottom=0;rounded=0;shadow=0;strokeWidth=1;" parent="WIyWlLk6GJQsqaUBKTNV-1" vertex="1">
<mxGeometry x="150" y="258" width="160" height="138" as="geometry">
<mxRectangle x="130" y="380" width="160" height="26" as="alternateBounds" />
</mxGeometry>
</mxCell>
<mxCell id="zkfFHV4jXpPFQw0GAbJ--7" value="MenuItems" style="text;align=left;verticalAlign=top;spacingLeft=4;spacingRight=4;overflow=hidden;rotatable=0;points=[[0,0.5],[1,0.5]];portConstraint=eastwest;" parent="zkfFHV4jXpPFQw0GAbJ--6" vertex="1">
<mxGeometry y="26" width="160" height="26" as="geometry" />
</mxCell>
<mxCell id="zkfFHV4jXpPFQw0GAbJ--9" value="" style="line;html=1;strokeWidth=1;align=left;verticalAlign=middle;spacingTop=-1;spacingLeft=3;spacingRight=3;rotatable=0;labelPosition=right;points=[];portConstraint=eastwest;" parent="zkfFHV4jXpPFQw0GAbJ--6" vertex="1">
<mxGeometry y="52" width="160" height="8" as="geometry" />
</mxCell>
<mxCell id="zkfFHV4jXpPFQw0GAbJ--11" value="Menu()" style="text;align=left;verticalAlign=top;spacingLeft=4;spacingRight=4;overflow=hidden;rotatable=0;points=[[0,0.5],[1,0.5]];portConstraint=eastwest;" parent="zkfFHV4jXpPFQw0GAbJ--6" vertex="1">
<mxGeometry y="60" width="160" height="26" as="geometry" />
</mxCell>
<mxCell id="A6uXA1JAniuv3VXLVRst-31" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;exitX=0.5;exitY=0;exitDx=0;exitDy=0;entryX=0;entryY=0.5;entryDx=0;entryDy=0;" parent="WIyWlLk6GJQsqaUBKTNV-1" source="A6uXA1JAniuv3VXLVRst-0" target="zkfFHV4jXpPFQw0GAbJ--7" edge="1">
<mxGeometry relative="1" as="geometry">
<Array as="points">
<mxPoint x="230" y="420" />
<mxPoint x="130" y="420" />
<mxPoint x="130" y="297" />
</Array>
</mxGeometry>
</mxCell>
<mxCell id="A6uXA1JAniuv3VXLVRst-0" value="MenuItem" style="swimlane;fontStyle=0;align=center;verticalAlign=top;childLayout=stackLayout;horizontal=1;startSize=26;horizontalStack=0;resizeParent=1;resizeLast=0;collapsible=1;marginBottom=0;rounded=0;shadow=0;strokeWidth=1;" parent="WIyWlLk6GJQsqaUBKTNV-1" vertex="1">
<mxGeometry x="150" y="440" width="160" height="138" as="geometry">
<mxRectangle x="130" y="380" width="160" height="26" as="alternateBounds" />
</mxGeometry>
</mxCell>
<mxCell id="A6uXA1JAniuv3VXLVRst-27" value="- label" style="text;align=left;verticalAlign=top;spacingLeft=4;spacingRight=4;overflow=hidden;rotatable=0;points=[[0,0.5],[1,0.5]];portConstraint=eastwest;" parent="A6uXA1JAniuv3VXLVRst-0" vertex="1">
<mxGeometry y="26" width="160" height="26" as="geometry" />
</mxCell>
<mxCell id="A6uXA1JAniuv3VXLVRst-1" value="- action" style="text;align=left;verticalAlign=top;spacingLeft=4;spacingRight=4;overflow=hidden;rotatable=0;points=[[0,0.5],[1,0.5]];portConstraint=eastwest;" parent="A6uXA1JAniuv3VXLVRst-0" vertex="1">
<mxGeometry y="52" width="160" height="26" as="geometry" />
</mxCell>
<mxCell id="A6uXA1JAniuv3VXLVRst-3" value="" style="line;html=1;strokeWidth=1;align=left;verticalAlign=middle;spacingTop=-1;spacingLeft=3;spacingRight=3;rotatable=0;labelPosition=right;points=[];portConstraint=eastwest;" parent="A6uXA1JAniuv3VXLVRst-0" vertex="1">
<mxGeometry y="78" width="160" height="8" as="geometry" />
</mxCell>
<mxCell id="A6uXA1JAniuv3VXLVRst-5" value="MenuItem()" style="text;align=left;verticalAlign=top;spacingLeft=4;spacingRight=4;overflow=hidden;rotatable=0;points=[[0,0.5],[1,0.5]];portConstraint=eastwest;" parent="A6uXA1JAniuv3VXLVRst-0" vertex="1">
<mxGeometry y="86" width="160" height="26" as="geometry" />
</mxCell>
<mxCell id="A6uXA1JAniuv3VXLVRst-29" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;exitX=0.5;exitY=0;exitDx=0;exitDy=0;entryX=1;entryY=0.5;entryDx=0;entryDy=0;" parent="WIyWlLk6GJQsqaUBKTNV-1" source="A6uXA1JAniuv3VXLVRst-15" target="zkfFHV4jXpPFQw0GAbJ--1" edge="1">
<mxGeometry relative="1" as="geometry" />
</mxCell>
<mxCell id="A6uXA1JAniuv3VXLVRst-15" value="Station" style="swimlane;fontStyle=0;align=center;verticalAlign=top;childLayout=stackLayout;horizontal=1;startSize=26;horizontalStack=0;resizeParent=1;resizeLast=0;collapsible=1;marginBottom=0;rounded=0;shadow=0;strokeWidth=1;" parent="WIyWlLk6GJQsqaUBKTNV-1" vertex="1">
<mxGeometry x="520" y="258" width="160" height="138" as="geometry">
<mxRectangle x="130" y="380" width="160" height="26" as="alternateBounds" />
</mxGeometry>
</mxCell>
<mxCell id="A6uXA1JAniuv3VXLVRst-16" value="Departures : List&lt;Departure&gt;" style="text;align=left;verticalAlign=top;spacingLeft=4;spacingRight=4;overflow=hidden;rotatable=0;points=[[0,0.5],[1,0.5]];portConstraint=eastwest;" parent="A6uXA1JAniuv3VXLVRst-15" vertex="1">
<mxGeometry y="26" width="160" height="26" as="geometry" />
</mxCell>
<mxCell id="A6uXA1JAniuv3VXLVRst-18" value="" style="line;html=1;strokeWidth=1;align=left;verticalAlign=middle;spacingTop=-1;spacingLeft=3;spacingRight=3;rotatable=0;labelPosition=right;points=[];portConstraint=eastwest;" parent="A6uXA1JAniuv3VXLVRst-15" vertex="1">
<mxGeometry y="52" width="160" height="8" as="geometry" />
</mxCell>
<mxCell id="A6uXA1JAniuv3VXLVRst-20" value="Station()" style="text;align=left;verticalAlign=top;spacingLeft=4;spacingRight=4;overflow=hidden;rotatable=0;points=[[0,0.5],[1,0.5]];portConstraint=eastwest;" parent="A6uXA1JAniuv3VXLVRst-15" vertex="1">
<mxGeometry y="60" width="160" height="26" as="geometry" />
</mxCell>
<mxCell id="A6uXA1JAniuv3VXLVRst-32" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;exitX=0.5;exitY=0;exitDx=0;exitDy=0;" parent="WIyWlLk6GJQsqaUBKTNV-1" source="A6uXA1JAniuv3VXLVRst-21" target="A6uXA1JAniuv3VXLVRst-16" edge="1">
<mxGeometry relative="1" as="geometry">
<Array as="points">
<mxPoint x="600" y="420" />
<mxPoint x="700" y="420" />
<mxPoint x="700" y="297" />
</Array>
</mxGeometry>
</mxCell>
<mxCell id="A6uXA1JAniuv3VXLVRst-21" value="Departure" style="swimlane;fontStyle=0;align=center;verticalAlign=top;childLayout=stackLayout;horizontal=1;startSize=26;horizontalStack=0;resizeParent=1;resizeLast=0;collapsible=1;marginBottom=0;rounded=0;shadow=0;strokeWidth=1;" parent="WIyWlLk6GJQsqaUBKTNV-1" vertex="1">
<mxGeometry x="520" y="440" width="490" height="502" as="geometry">
<mxRectangle x="130" y="380" width="160" height="26" as="alternateBounds" />
</mxGeometry>
</mxCell>
<mxCell id="A6uXA1JAniuv3VXLVRst-22" value="- delay : Duration" style="text;align=left;verticalAlign=top;spacingLeft=4;spacingRight=4;overflow=hidden;rotatable=0;points=[[0,0.5],[1,0.5]];portConstraint=eastwest;" parent="A6uXA1JAniuv3VXLVRst-21" vertex="1">
<mxGeometry y="26" width="490" height="26" as="geometry" />
</mxCell>
<mxCell id="A6uXA1JAniuv3VXLVRst-33" value="- track : int" style="text;align=left;verticalAlign=top;spacingLeft=4;spacingRight=4;overflow=hidden;rotatable=0;points=[[0,0.5],[1,0.5]];portConstraint=eastwest;" parent="A6uXA1JAniuv3VXLVRst-21" vertex="1">
<mxGeometry y="52" width="490" height="26" as="geometry" />
</mxCell>
<mxCell id="A6uXA1JAniuv3VXLVRst-23" value="- ORIGINALDEPARTURETIME : LocalTime" style="text;align=left;verticalAlign=top;spacingLeft=4;spacingRight=4;overflow=hidden;rotatable=0;points=[[0,0.5],[1,0.5]];portConstraint=eastwest;rounded=0;shadow=0;html=0;" parent="A6uXA1JAniuv3VXLVRst-21" vertex="1">
<mxGeometry y="78" width="490" height="26" as="geometry" />
</mxCell>
<mxCell id="A6uXA1JAniuv3VXLVRst-34" value="- DESTINATION : String" style="text;align=left;verticalAlign=top;spacingLeft=4;spacingRight=4;overflow=hidden;rotatable=0;points=[[0,0.5],[1,0.5]];portConstraint=eastwest;" parent="A6uXA1JAniuv3VXLVRst-21" vertex="1">
<mxGeometry y="104" width="490" height="26" as="geometry" />
</mxCell>
<mxCell id="A6uXA1JAniuv3VXLVRst-35" value="- LINE : String" style="text;align=left;verticalAlign=top;spacingLeft=4;spacingRight=4;overflow=hidden;rotatable=0;points=[[0,0.5],[1,0.5]];portConstraint=eastwest;" parent="A6uXA1JAniuv3VXLVRst-21" vertex="1">
<mxGeometry y="130" width="490" height="26" as="geometry" />
</mxCell>
<mxCell id="A6uXA1JAniuv3VXLVRst-36" value="- TRAINNUMBER: String" style="text;align=left;verticalAlign=top;spacingLeft=4;spacingRight=4;overflow=hidden;rotatable=0;points=[[0,0.5],[1,0.5]];portConstraint=eastwest;" parent="A6uXA1JAniuv3VXLVRst-21" vertex="1">
<mxGeometry y="156" width="490" height="26" as="geometry" />
</mxCell>
<mxCell id="A6uXA1JAniuv3VXLVRst-24" value="" style="line;html=1;strokeWidth=1;align=left;verticalAlign=middle;spacingTop=-1;spacingLeft=3;spacingRight=3;rotatable=0;labelPosition=right;points=[];portConstraint=eastwest;" parent="A6uXA1JAniuv3VXLVRst-21" vertex="1">
<mxGeometry y="182" width="490" height="8" as="geometry" />
</mxCell>
<mxCell id="A6uXA1JAniuv3VXLVRst-26" value="+ Departure(trainNumber : int, destination : String, departureTime : LocalTime)" style="text;align=left;verticalAlign=top;spacingLeft=4;spacingRight=4;overflow=hidden;rotatable=0;points=[[0,0.5],[1,0.5]];portConstraint=eastwest;" parent="A6uXA1JAniuv3VXLVRst-21" vertex="1">
<mxGeometry y="190" width="490" height="26" as="geometry" />
</mxCell>
<mxCell id="BCETesxdeNe0COvkHlKA-0" value="+ setDelay(duration : Duration) : void" style="text;align=left;verticalAlign=top;spacingLeft=4;spacingRight=4;overflow=hidden;rotatable=0;points=[[0,0.5],[1,0.5]];portConstraint=eastwest;" parent="A6uXA1JAniuv3VXLVRst-21" vertex="1">
<mxGeometry y="216" width="490" height="26" as="geometry" />
</mxCell>
<mxCell id="BCETesxdeNe0COvkHlKA-3" value="+ getDelay() : Duration" style="text;align=left;verticalAlign=top;spacingLeft=4;spacingRight=4;overflow=hidden;rotatable=0;points=[[0,0.5],[1,0.5]];portConstraint=eastwest;" parent="A6uXA1JAniuv3VXLVRst-21" vertex="1">
<mxGeometry y="242" width="490" height="26" as="geometry" />
</mxCell>
<mxCell id="BCETesxdeNe0COvkHlKA-4" value="+ setTrack(trackNumber : int) : void" style="text;align=left;verticalAlign=top;spacingLeft=4;spacingRight=4;overflow=hidden;rotatable=0;points=[[0,0.5],[1,0.5]];portConstraint=eastwest;" parent="A6uXA1JAniuv3VXLVRst-21" vertex="1">
<mxGeometry y="268" width="490" height="26" as="geometry" />
</mxCell>
<mxCell id="BCETesxdeNe0COvkHlKA-5" value="+ getTrack() : int" style="text;align=left;verticalAlign=top;spacingLeft=4;spacingRight=4;overflow=hidden;rotatable=0;points=[[0,0.5],[1,0.5]];portConstraint=eastwest;" parent="A6uXA1JAniuv3VXLVRst-21" vertex="1">
<mxGeometry y="294" width="490" height="26" as="geometry" />
</mxCell>
<mxCell id="BCETesxdeNe0COvkHlKA-6" value="+ getCurrentDepartureTime() : LocalTime" style="text;align=left;verticalAlign=top;spacingLeft=4;spacingRight=4;overflow=hidden;rotatable=0;points=[[0,0.5],[1,0.5]];portConstraint=eastwest;" parent="A6uXA1JAniuv3VXLVRst-21" vertex="1">
<mxGeometry y="320" width="490" height="26" as="geometry" />
</mxCell>
<mxCell id="BCETesxdeNe0COvkHlKA-7" value="+ getOriginalDepartureTime() : LocalTime" style="text;align=left;verticalAlign=top;spacingLeft=4;spacingRight=4;overflow=hidden;rotatable=0;points=[[0,0.5],[1,0.5]];portConstraint=eastwest;" parent="A6uXA1JAniuv3VXLVRst-21" vertex="1">
<mxGeometry y="346" width="490" height="26" as="geometry" />
</mxCell>
<mxCell id="BCETesxdeNe0COvkHlKA-8" value="+ getDestination() : String" style="text;align=left;verticalAlign=top;spacingLeft=4;spacingRight=4;overflow=hidden;rotatable=0;points=[[0,0.5],[1,0.5]];portConstraint=eastwest;" parent="A6uXA1JAniuv3VXLVRst-21" vertex="1">
<mxGeometry y="372" width="490" height="26" as="geometry" />
</mxCell>
<mxCell id="BCETesxdeNe0COvkHlKA-9" value="+ getLine() : String" style="text;align=left;verticalAlign=top;spacingLeft=4;spacingRight=4;overflow=hidden;rotatable=0;points=[[0,0.5],[1,0.5]];portConstraint=eastwest;" parent="A6uXA1JAniuv3VXLVRst-21" vertex="1">
<mxGeometry y="398" width="490" height="26" as="geometry" />
</mxCell>
<mxCell id="BCETesxdeNe0COvkHlKA-10" value="+ getTrainNumber() : int" style="text;align=left;verticalAlign=top;spacingLeft=4;spacingRight=4;overflow=hidden;rotatable=0;points=[[0,0.5],[1,0.5]];portConstraint=eastwest;" parent="A6uXA1JAniuv3VXLVRst-21" vertex="1">
<mxGeometry y="424" width="490" height="26" as="geometry" />
</mxCell>
</root>
</mxGraphModel>
</diagram>
</mxfile>
...@@ -2,19 +2,32 @@ package edu.ntnu.stud.menubuilder; ...@@ -2,19 +2,32 @@ package edu.ntnu.stud.menubuilder;
import edu.ntnu.stud.menubuilder.menu.Menu; import edu.ntnu.stud.menubuilder.menu.Menu;
import edu.ntnu.stud.menubuilder.trainz.Station; import edu.ntnu.stud.menubuilder.trainz.Station;
import java.util.ArrayList;
import java.util.List;
/** . /** .
* *
*/ */
public class UserInterface { public class UserInterface {
private Menu mainMenu; private Menu mainMenu;
private Menu searchDepartures;
private Station station; private Station station;
private static Menu buildSubmenu(String menuName, Station myStation) { /** Builds a temporary menu.
*
* @param menuName A String representing the name of the menu.
* @param myStation A Station representing the station the menu is related to.
* @return a Menu representing a menu.
*/
public static Menu buildSubmenu(String menuName, Station myStation) {
Menu tmpMenu = new Menu(menuName); Menu tmpMenu = new Menu(menuName);
//logic to make MenuItems for the Menu goes here //logic to make MenuItems for the Menu goes here
// Fetch list of relevant data from myStation
// iteratively make menuItems for tmpMenu
// label for menuItem
// runnable to manipulate object the menuItem represents in the submenu
return tmpMenu; return tmpMenu;
} }
...@@ -26,10 +39,12 @@ public class UserInterface { ...@@ -26,10 +39,12 @@ public class UserInterface {
public void init() { public void init() {
station = new Station(); station = new Station();
mainMenu = new Menu("Example Main Menu"); mainMenu = new Menu("Example Main Menu");
searchDepartures = new Menu(null);
mainMenu.newEntry("Option 1", () -> System.out.println("Execute Option 1")); mainMenu.newEntry("Option 1", () -> System.out.println("Execute Option 1"));
mainMenu.newEntry("Option 2", () -> System.out.println("Execute Option 2")); mainMenu.newEntry("Option 2", () -> System.out.println("Execute Option 2"));
mainMenu.newEntry("Option 3", () -> System.out.println("Execute Option 3")); mainMenu.newEntry("Option 3", () -> System.out.println("Execute Option 3"));
mainMenu.newEntry("Submenu 4", () -> UserInterface.buildSubmenu("Option 4", station)); mainMenu.newEntry("Submenu 4", () ->
UserInterface.buildSubmenu("Option 4", station).displayMenu(true));
} }
......
...@@ -4,11 +4,12 @@ import java.util.ArrayList; ...@@ -4,11 +4,12 @@ import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Scanner; import java.util.Scanner;
/** Represent a menu. /** Represents a menu.
* This class is from my solution to "Øving 11".
* *
* @author Lars-Johan Larsen * @author Lars-Johan Larsen
* @version 1.0 * @version 1.0
* @since 1.0 * @since 0
*/ */
public class Menu { public class Menu {
private String title; private String title;
......
package edu.ntnu.stud.menubuilder.menu; package edu.ntnu.stud.menubuilder.menu;
/** Represent an item in a menu. /** Represent an item in a menu.
* This class is from my solution to "Øving 11".
* *
* @author Lars-Johan Larsen * @author Lars-Johan Larsen
* @version 1.0 * @version 1.0
* @since 1.0 * @since 0
*/ */
class MenuItem { class MenuItem {
private String label; private String label;
...@@ -16,9 +17,9 @@ class MenuItem { ...@@ -16,9 +17,9 @@ class MenuItem {
} }
/** gets an item's label. /** Gets an item's label.
* *
* @return A String representing a menu item's label. * @return A String representing a label for an item menu.
*/ */
public String getLabel() { public String getLabel() {
return label; return label;
......
...@@ -23,8 +23,10 @@ class Departure { ...@@ -23,8 +23,10 @@ class Departure {
/** Throws an error if invalid input is given to Departure(). /** Throws an error if invalid input is given to Departure().
* *
* @param duration A Duration representing a delay. * @param trainNumber An int representing a train.
* @throws IllegalArgumentException For illegal durations. * @param line A String representing a train line between two locations.
* @param destination A String representing a destination.
* @throws IllegalArgumentException For illegal values.
*/ */
private void verifyDeparture( private void verifyDeparture(
int trainNumber, String line, String desination) { int trainNumber, String line, String desination) {
...@@ -49,6 +51,13 @@ class Departure { ...@@ -49,6 +51,13 @@ class Departure {
} }
/** Constructs a Departure object, representing a departure.
*
* @param trainNumber An int representing the unique identifier of a train.
* @param line A String representing a train line between two locations.
* @param destination A String representing the destination of this departure.
* @param departureTime A LocalDateTime object representing original time of Departure.
*/
public Departure(int trainNumber, String line, String destination, LocalDateTime departureTime) { public Departure(int trainNumber, String line, String destination, LocalDateTime departureTime) {
verifyDeparture(trainNumber, line, destination); verifyDeparture(trainNumber, line, destination);
this.trainNumber = trainNumber; this.trainNumber = trainNumber;
...@@ -85,7 +94,7 @@ class Departure { ...@@ -85,7 +94,7 @@ class Departure {
this.delay = duration; this.delay = duration;
} }
/** Gets the delay for this departure. /** Gets the Duration representing the delay for this departure.
* *
* @return a Duration representing a delay. * @return a Duration representing a delay.
*/ */
...@@ -110,7 +119,7 @@ class Departure { ...@@ -110,7 +119,7 @@ class Departure {
} }
} }
/** Sets the track number for this departure. /** Sets an int representing the track number for this departure.
* *
* @param trackNumber A possitive int above 0 representing a track, or -1 for no track set. * @param trackNumber A possitive int above 0 representing a track, or -1 for no track set.
* @throws IllegalArgumentException if the provided track number is less than 0 and not -1. * @throws IllegalArgumentException if the provided track number is less than 0 and not -1.
...@@ -120,7 +129,7 @@ class Departure { ...@@ -120,7 +129,7 @@ class Departure {
this.track = trackNumber; this.track = trackNumber;
} }
/** Gets the current track number for this departure. /** Gets an int representing the current track number for this departure.
* *
* @return A possitive int above 0 representing a track, or -1 if no track is set. * @return A possitive int above 0 representing a track, or -1 if no track is set.
*/ */
...@@ -132,7 +141,8 @@ class Departure { ...@@ -132,7 +141,8 @@ class Departure {
// departure methods // departure methods
/** Gets the current departure time, factoring in the current delay. /** Gets the LocalDateTime representing the current departure time,
* factoring in the current delay.
* *
* @return a LocalDateTime representing a time of the day. * @return a LocalDateTime representing a time of the day.
*/ */
...@@ -140,7 +150,8 @@ class Departure { ...@@ -140,7 +150,8 @@ class Departure {
return this.originalDepartureTime.plus(this.delay); return this.originalDepartureTime.plus(this.delay);
} }
/** Gets the originally planned departure time, without factoring in the current delay. /** Gets LocalDateTime representing the original departure time,
* without factoring in the current delay.
* *
* @return a LocalDateTime representing a time of the day. * @return a LocalDateTime representing a time of the day.
*/ */
...@@ -151,7 +162,7 @@ class Departure { ...@@ -151,7 +162,7 @@ class Departure {
// destination methods // destination methods
/** Gets the destination of this departure. /** Gets a String representing the destination of this departure.
* *
* @return A String representing a destination. * @return A String representing a destination.
*/ */
...@@ -162,9 +173,6 @@ class Departure { ...@@ -162,9 +173,6 @@ class Departure {
// line methods // line methods
/** Gets the line for this departure. /** Gets the line for this departure.
* *
* @return A String representing a line. * @return A String representing a line.
......
...@@ -2,7 +2,7 @@ package edu.ntnu.stud.menubuilder.trainz; ...@@ -2,7 +2,7 @@ package edu.ntnu.stud.menubuilder.trainz;
import java.time.Duration; import java.time.Duration;
public class InformationBoard { class InformationBoard {
public String getInformationBoardEntry(int collumnWidth, Departure departure) { public String getInformationBoardEntry(int collumnWidth, Departure departure) {
StringBuilder stringBuilder = new StringBuilder("|"); StringBuilder stringBuilder = new StringBuilder("|");
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment