Finished basic airline JUnit test

This commit is contained in:
YaFedImYaEatIm
2016-08-22 18:36:10 +12:00
parent ccb852e670
commit c096cf07dc
3 changed files with 82 additions and 14 deletions
+20 -3
View File
@@ -39,7 +39,7 @@ public class Airline {
this.callSign = callSign;
this.active = active;
this.country = country;
routes = new ArrayList<Route>();
this.routes = new ArrayList<Route>();
}
/**
@@ -105,7 +105,13 @@ public class Airline {
* @param routes
*/
public void setRoutes(ArrayList<Route> routes) {
this.routes = routes;
//this is necessary so that the object routes arraylist does not
//point the the other list which will result to data errors. THus
//a clone must be made.
this.routes = new ArrayList<Route>();
for(int i = 0; i < routes.size();i ++){
this.routes.add(routes.get(i));
}
}
/**
* get the ID of relative to the database
@@ -175,7 +181,18 @@ public class Airline {
* @param route
*/
public void addRoutes(Route route){
routes.add(route);
ArrayList<Route> routesToAdd = new ArrayList<Route>();
routesToAdd.add(route);
addRoutes(routesToAdd);
}
/**
* Function Overload of addRoutes this allow the adding of a list to route
* @param routes
*/
public void addRoutes(ArrayList<Route> routesToAdd){
for (int i = 0; i < routesToAdd.size(); i ++){
routes.add(routesToAdd.get(i));
}
}
/**
* returns the name of the airline when concatenated to a string.
+23 -3
View File
@@ -6,7 +6,7 @@ package seng202.group9.Core;
*
*/
public class Route {
private int ID;
private int ID;//this ID is the route id not the airline or airports.
private int stops;
private String codeShare;
private String equipment;
@@ -14,7 +14,7 @@ public class Route {
private String departureAirport;
private String arrivalAirport;
/**
* Constructor
* Constructor for pulling from database
* @param airline
* @param ID
* @param departureAirport
@@ -23,7 +23,7 @@ public class Route {
* @param stops
* @param equipment
*/
public Route(String airline, int ID, String departureAirport, String arrivalAirport,
public Route(int ID, String airline, String departureAirport, String arrivalAirport,
String codeShare, int stops, String equipment){
this.ID = ID;
this.stops = stops;
@@ -33,6 +33,26 @@ public class Route {
this.departureAirport = departureAirport;
this.arrivalAirport = arrivalAirport;
}
/**
* Constructor for adding
* @param airline
* @param departureAirport
* @param arrivalAirport
* @param codeShare
* @param stops
* @param equipment
*/
public Route(String airline, String departureAirport, String arrivalAirport,
String codeShare, int stops, String equipment){
//remember to set the id manually later after adding it to the database and grab
//the new id value of the route.
this.stops = stops;
this.codeShare = codeShare;
this.equipment = equipment;
this.airline = airline;
this.departureAirport = departureAirport;
this.arrivalAirport = arrivalAirport;
}
/**
* Returns code share of the route
* @return