Added Javadoc Strings for Some functions

main
YaFedImYaEatIm 9 years ago
parent 9e00e3666f
commit 724f63956a

@ -22,7 +22,7 @@ public class Airline{
private Country country = null;
/**
* Constructor
* Constructor for Airline when pulled from the database.
*
* @param ID
* @param name
@ -45,7 +45,16 @@ public class Airline{
this.routes = new ArrayList<Route>();
}
/**
* Constructor for Airline without ID this will be set later by the dataset from the dataset.
* @param name
* @param alias
* @param IATA
* @param ICAO
* @param callSign
* @param countryName
* @param active
*/
public Airline(String name, String alias, String IATA, String ICAO, String callSign, String countryName, String active){
this.ID = -1;
this.IATA = IATA;
@ -255,6 +264,9 @@ public class Airline{
if (this.name.equals(airline.getName())){
throw new DataException("This Airline Name already Exists, Please Choose Another.");
}
if (this.name.equals("")){
throw new DataException("This Airline Name cannot be Empty");
}
if (!this.IATA.equals("") && this.IATA.equals(airline.getIATA())){
throw new DataException("This IATA Code already Exists, Please Choose Another.");
}
@ -273,7 +285,7 @@ public class Airline{
*/
@Override
public String toString(){
return name;
return name + ", IATA:" + IATA + ", ICAO: " + ICAO;
}
}

@ -89,6 +89,11 @@ public class Airport {
public void setID(int iD) {
this.ID = iD;
}
/**
* Sets the Name of the Airport.
* @param name
*/
public void setName(String name){
this.name = name;
}
@ -148,10 +153,18 @@ public class Airport {
}
}
/**
* gets the country name
* @return
*/
public String getCountryName() {
return countryName;
}
/**
* sets the country name
* @param countryName
*/
public void setCountryName(String countryName) {
this.countryName = countryName;
}
@ -194,13 +207,6 @@ public class Airport {
public String getICAO(){
return ICAO;
}
/**
* gets the IATA/FFA of the airport
* @return IATA/FFA Code
*/
// public String IATA_FFA(){
// return IATA_FFA;
// }
/**
* gets the altitude of the airport
* @return Altitude of Airport
@ -254,7 +260,10 @@ public class Airport {
return country;
}
//JavaDoc needed
/**
* gets the timezone of the Airport
* @return
*/
public Double getTimezone() {
if (this.city != null) {
return this.city.getTimezone();
@ -262,7 +271,11 @@ public class Airport {
return 0.0;
}
}
//JavaDoc needed
/**
* gets the DST of the Country the Airport is in.
* @return
*/
public String getDST() {
if (this.country != null) {
return this.country.getDST();
@ -270,7 +283,11 @@ public class Airport {
return "";
}
}
//JavaDoc needed
/**
* gets the timezone in Olson format of the country the airport is in
* @return
*/
public String getTz() {
if (this.city != null) {
return this.city.getTimeOlson();
@ -364,6 +381,12 @@ public class Airport {
distance = 6371 * c;
return distance;
}
/**
* Checks if the airport is a semi duplicate of this class. Used to see if it passes to enter into the Database.
* @param airport
* @throws DataException
*/
public void hasDuplicate(Airport airport) throws DataException{
if (airport.getName().equals("") || airport.getName().equals(this.name)){
throw new DataException("Airport Name already Exists, Please Choose Another.");
@ -378,7 +401,6 @@ public class Airport {
/**
* Information of the airport returned in String format.
*/
@Override
public String toString(){
return this.cityName +" Airport has ICAO: "+this.ICAO+", IATA/FFA: "+this.IATA_FFA+" and is located at ("+this.latitude+", "+this.longitude

@ -8,7 +8,14 @@ public class City {
private double timezone;
private String timeOlson;
private ArrayList<Airport> airports;
/**
* City Constructor
* @param name
* @param country
* @param timezone
* @param timeOlson
*/
public City(String name, String country, double timezone, String timeOlson){
this.name = name;
this.country = country;
@ -16,23 +23,43 @@ public class City {
this.timeOlson = timeOlson;
this.airports = new ArrayList<Airport>();
}
/**
* Sets Name of the City
* @param name
*/
public void setName(String name) {
this.name = name;
}
/**
* Sets Country that the city is in.
* @param country
*/
public void setCountry(String country){
this.country = country;
}
/**
* Set Timezone that the City is in.
* @param timezone
*/
public void setTimezone(double timezone) {
this.timezone = timezone;
}
/**
* Sets the time olson the city is in.
* @param timeOlson
*/
public void setTimeOlson(String timeOlson) {
this.timeOlson = timeOlson;
}
/**
* Sets the airports the are in the city
* @param airports
*/
public void setAirports(ArrayList<Airport> airports) {
this.airports = new ArrayList<Airport>();
for (int i = 0; i < airports.size(); i ++) {
@ -40,46 +67,81 @@ public class City {
}
}
/**
* Gets the name of the city.
* @return
*/
public String getName(){
return name;
}
/**
* Gets the Country that the city is in.
* @return
*/
public String getCountry(){
return country;
}
/**
* gets the Timezone that the City is in.
* @return
*/
public double getTimezone(){
return timezone;
}
/**
* Gets the Timezone in Olson format the City is in.
* @return
*/
public String getTimeOlson(){
return timeOlson;
}
/**
* gets the Airports that are in this city.
* @return
*/
public ArrayList<Airport> getAirports(){
return airports;
}
/**
* adds an airport that is in this city.
* @param airport
*/
public void addAirport(Airport airport){
airports.add(airport);
}
/**
* adds multiple airports to this city.
* @param airports
*/
public void addAirport(ArrayList<Airport> airports){
for (int i = 0; i < airports.size(); i++){
addAirport(airports.get(i));
}
}
/**
* Deletes an Airport from this City.
* @param airport
*/
public void delAirport(Airport airport){
airports.remove(airport);
}
/**
* Deletes an Airport by Index from this City.
* @param index
*/
public void delAirport(int index) {
airports.remove(index);
}
@Override
public String toString(){
return this.name;
return this.name + " has " + airports.size() + " Airports and is in "+timeOlson;
}
}

@ -7,20 +7,37 @@ public class Country {
private ArrayList<City> cities = new ArrayList<City>();
private ArrayList<Airline> airlines = new ArrayList<Airline>();
private Position position;
/**
* Contructor for Country.
* @param DST
* @param name
*/
public Country(String DST, String name){
this.DST = DST;
this.name = name;
}
/**
* Sets the DST of the country.
* @param dST
*/
public void setDST(String dST) {
DST = dST;
}
/**
* Sets the name of the country.
* @param name
*/
public void setName(String name) {
this.name = name;
}
/**
* Set Airlines that are based in this country.
* @param airlines
*/
public void setAirlines(ArrayList<Airline> airlines) {
this.airlines = new ArrayList<Airline>();
for (int i = 0; i < airlines.size(); i ++) {
@ -28,36 +45,68 @@ public class Country {
}
}
/**
* Gets the DST of the Country.
* @return
*/
public String getDST(){
return this.DST;
}
/**
* Gets the Name of the Country.
* @return
*/
public String getName(){
return this.name;
}
/**
* gets the Airlines that belong in this Country.
* @return
*/
public ArrayList<Airline> getAirlines(){
return airlines;
}
/**
* Adds an Airline that is based in this country.
* @param airline
*/
public void addAirline(Airline airline){
this.airlines.add(airline);
}
/**
* Adds multiple Airlines to this Country.
* @param airlines
*/
public void addAirline(ArrayList<Airline> airlines){
for (int i = 0; i < airlines.size(); i++){
addAirline(airlines.get(i));
}
}
/**
* deletes an Airline based in this country.
* @param airline
*/
public void delAirline(Airline airline){
airlines.remove(airline);
}
/**
* deletes an Airline in this country.
* @param index
*/
public void delAirline(int index){
airlines.remove(index);
}
/**
* sets the cities of this country
* @param cities
*/
public void setCities(ArrayList<City> cities){
this.cities = new ArrayList<City>();
for (int i = 0; i < cities.size(); i++){
@ -65,32 +114,60 @@ public class Country {
}
}
/**
* adds a City to this country.
* @param city
*/
public void addCities(City city){
this.cities.add(city);
}
/**
* Add multiple Cities to this Country.
* @param cities
*/
public void addCities(ArrayList<City> cities){
for (int i = 0; i < cities.size(); i++){
this.cities.add(cities.get(i));
}
}
/**
* Deletes a city for this country.
* @param city
*/
public void delCities(City city){
this.cities.remove(city);
}
/**
* Deletes Cities in this Country
* @param index
*/
public void delCities(int index){
this.cities.remove(index);
}
/**
* Gets the CIties in this Country.
* @return
*/
public ArrayList<City> getCities() {
return cities;
}
/**
* gets the {@link Position}(double Latitude, double Longitude) of this Country.
* @return
*/
public Position getPosition() {
return position;
}
/**
* sets the {@link Position} of the Country.
* @param position
*/
public void setPosition(Position position) {
this.position = position;
}

@ -10,7 +10,7 @@ public class FlightPath {
final private RoutePath routePath = new RoutePath();
/**
*
* Constructor for this FLight Path from database
* @param ID id of the the flight path in the database
* @param departureAirport Iata/FFA of the airport
* @param arrivalAirport IATA/FFA of the airport
@ -22,17 +22,30 @@ public class FlightPath {
this.flightPoints = new ArrayList<FlightPoint>();
}
/**
* COnstructor for FlightPath from dataset add later the ID needs to be set from database.
* @param departureAirport
* @param arrivalAirport
*/
public FlightPath(String departureAirport, String arrivalAirport){
this.ID = -1;
this.departureAirport = departureAirport;
this.arrivalAirport = arrivalAirport;
this.flightPoints = new ArrayList<FlightPoint>();
}
/**
* Gets the {@link FlightPoint} of this flight Path.
* @return
*/
public ArrayList<FlightPoint> getFlightPoints() {
return flightPoints;
}
/**
* Sets the {@link FlightPoint} of this Flight Path.
* @param flightPoints
*/
public void setFlightPoints(ArrayList<FlightPoint> flightPoints) {
this.flightPoints = new ArrayList<FlightPoint>();
for (int i = 0; i < flightPoints.size(); i ++) {
@ -40,56 +53,112 @@ public class FlightPath {
}
}
/**
* Sets the {@link Airport} that the Flight Path leaves from.
* @param departureAirport
*/
public void setDepartureAirport(String departureAirport) {
this.departureAirport = departureAirport;
}
/**
* Sets the {@link Airport} that the Flight Path arrives at.
* @param arrivalAirport
*/
public void setArrivalAirport(String arrivalAirport) {
this.arrivalAirport = arrivalAirport;
}
/**
* Sets the ID that corresponds to the database for this flight path.
* Also the ID that corresponds to {@see FlightPoint} IndexID
* @param iD
*/
public void setID(int iD) {
ID = iD;
}
/**
* gets the ID of the Flight Path.
* @return
*/
public int getID(){
return ID;
}
/**
* gets the {@link Airport} that the FLight Departs from.
* @return
*/
public String departsFrom(){
return departureAirport;
}
/**
* gets the {@link Airport} that the flight arrives at.
* @return
*/
public String arrivesAt(){
return arrivalAirport;
}
/**
* Gets all the Points that the FLight passes
* {@link FlightPoint}
* @return
*/
public ArrayList<FlightPoint> getFlight(){
return flightPoints;
}
/**
* Adds a {@link FlightPoint} to the Flight Path.
* @param flightPoint
*/
public void addFlightPoint(FlightPoint flightPoint){
flightPoints.add(flightPoint);
}
/**
* Adds a {@link FlightPoint} to the Flight Path at a specific point of the flight.
* @param flightPoint
* @param index
*/
public void addFlightPoint(FlightPoint flightPoint, int index){
flightPoints.add(index, flightPoint);
}
/**
* deletes a point from the flight.
* @param flightPoint
*/
public void delFlightPoint(FlightPoint flightPoint){
flightPoints.remove(flightPoint);
}
/**
* delets a point from the flight at a specific index.
* @param index
*/
public void delFlightPoint(int index){
flightPoints.remove(index);
}
/**
* Adds multiple {@link FlightPoint} to the FlightPath.
* @param flightPoints
*/
public void addFlightPoint(ArrayList<FlightPoint> flightPoints){
for (int i = 0; i < flightPoints.size(); i ++){
this.flightPoints.add(flightPoints.get(i));
}
}
/**
* Gets the {@link RoutePath} that the FlightPath traverses.
* Also see {@see seng202.group9.Map.Map}
* @return
*/
public RoutePath getRoutePath(){
if (routePath.getRoute().size() == 0){
for (FlightPoint point: flightPoints){

@ -15,6 +15,14 @@ public class FlightPoint {
private double latitude;
private double longitude;
/**
* Constructor for FLight POint before set by the database.
* @param type
* @param name
* @param altitude
* @param latitude
* @param longitude
*/
public FlightPoint(String type, String name, double altitude, double latitude, double longitude){
//extra calculations will have to be used to find heading, legdistance and total distance. If necessary
//Type 1 file the file the lecturers gave us
@ -33,6 +41,20 @@ public class FlightPoint {
this.longitude = longitude;
}
/**
* Constructor when getting points from the database.
* @param name Name for the point.
* @param ID Unique ID from Database.
* @param indexID FOreighn key for {@link FlightPath}.
* @param type
* @param via
* @param heading
* @param altitude
* @param legDistance
* @param totalDistance
* @param latitude
* @param longitude
*/
public FlightPoint(String name, int ID, int indexID, String type, String via,
int heading, double altitude, double legDistance, double totalDistance,
double latitude, double longitude){
@ -49,6 +71,11 @@ public class FlightPoint {
this.longitude = longitude;
}
/**
* get the Path ID
* @return
* @throws DataException
*/
public int getIndexID() throws DataException {
if (this.ID == -1){
throw new DataException("ID not set.");
@ -57,54 +84,107 @@ public class FlightPoint {
}
}
/**
* sets the Path ID
* @param indexID
*/
public void setIndexID(int indexID) {
this.indexID = indexID;
}
/**
* sets the name of the path.
* @param name
*/
public void setName(String name) {
this.name = name;
}
/**
* sets the Unique Database ID of the Path
* @param iD
*/
public void setID(int iD) {
ID = iD;
}
/**
* Sets the type of the Point.
* @param type
*/
public void setType(String type) {
this.type = type;
}
/**
* set the VIA of the Point.
* @param via
*/
public void setVia(String via) {
this.via = via;
}
/**
* Sets bearing the flight is heading.
* @param heading
*/
public void setHeading(int heading) {
this.heading = heading;
}
/**
* sets the altitude of the flight at this point.
* @param altitude
*/
public void setAltitude(double altitude) {
this.altitude = altitude;
}
/**
* sets the distance this flight takes before the next point.
* @param legDistance
*/
public void setLegDistance(double legDistance) {
this.legDistance = legDistance;
}
/**
* sets total distance travelled at this point.
* @param totalDistance
*/
public void setTotalDistance(double totalDistance) {
this.totalDistance = totalDistance;
}
/**
* sets the latitude at this point.
* @param latitude
*/
public void setLatitude(double latitude) {
this.latitude = latitude;
}
/**
* Sets the Longitude at this point.
* @param longitude
*/
public void setLongitude(double longitude) {
this.longitude = longitude;
}
/**
* gets the name of this point.
* @return
*/
public String getName(){
return name;
}
/**
* gets the UNIQUE ID at this point.
* @return
* @throws DataException
*/
public int getID() throws DataException {
if (this.ID == -1){
throw new DataException("ID not set.");
@ -112,39 +192,75 @@ public class FlightPoint {
return ID;
}
}
/**
* gets the Path Index ID at this point.
* @return
*/
public int getIndex(){
return indexID;
}
/**
* gets the type of this point.
* @return
*/
public String getType(){
return type;
}
/**
* gets where the plane is via at this point.
* @return
*/
public String getVia(){
return via;
}
/**
* gets the Heading bearing at this point
* @return
*/
public int getHeading(){
return heading;
}
/**
* gets the altitude at this poitn.
* @return
*/
public double getAltitude(){
return altitude;
}
/**
* gets the leg distance at this point.
* @return
*/
public double getLegDistance(){
return legDistance;
}
/**
* gets total distance travelled by this flight so far.
* @return
*/
public double getTotalDistance(){
return totalDistance;
}
/**
* gets longitude of this point.
* @return
*/
public double getLongitude(){
return longitude;
}
/**
* gets the latitude of this point.
* @return
*/
public double getLatitude(){
return latitude;
}

@ -121,7 +121,12 @@ public class Route {
return ID;
}
}
//JavaDoc needed
/**
* Gets this ID of the Airline.
* @return
* @throws DataException
*/
public int getAirlineID() throws DataException {
if (this.getAirline() != null) {
return this.getAirline().getID();
@ -130,6 +135,11 @@ public class Route {
}
}
/**
* Gets the ID of the Airport that the Route leaves from.
* @return
* @throws DataException
*/
public int getSourceID() throws DataException {
if (this.getSourceAirport() != null) {
return this.getSourceAirport().getID();
@ -138,6 +148,11 @@ public class Route {
}
}
/**
* gets the destination ID of the Airport the Route is arriving at.
* @return
* @throws DataException
*/
public int getDestID() throws DataException {
if (this.getDestinationAirport() != null) {
return this.getDestinationAirport().getID();
@ -248,6 +263,10 @@ public class Route {
}
}
/**
* gets the RoutePath to be passed into {@link seng202.group9.Map.Map}.
* @return
*/
public RoutePath getRoutePath(){
if (routePath == null) {
routePath = new RoutePath(
@ -258,6 +277,10 @@ public class Route {
return routePath;
}
/**
* What to print if printed as a string.
* @return
*/
@Override
public String toString(){

@ -10,22 +10,41 @@ import java.util.Collections;
public class RoutePath {
private ArrayList<Position> route = new ArrayList<Position>();
/**
* Route Path constructor when the user knows the points.
* @param points
*/
public RoutePath(Position ...points) {
Collections.addAll(route, points);
}
/**
* Route Path constructor when the user doesn't know the points.
*/
public RoutePath(){
}
/**
* adds a {@link Position} to the RoutePath.
* @param position
*/
public void addPosition(Position position){
route.add(position);
}
/**
* Gets the RoutePath positions.
* @return
*/
public ArrayList<Position> getRoute() {
return route;
}
/**
* Converts the RoutePath to an Array in JSON which can then be passed to the Map to display.
* @return
*/
public String toJSONArray() {
StringBuilder stringBuilder = new StringBuilder();
stringBuilder.append("[");

Loading…
Cancel
Save