-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLineRoute.java
More file actions
137 lines (132 loc) · 6.66 KB
/
LineRoute.java
File metadata and controls
137 lines (132 loc) · 6.66 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
//
/*Eric Zacarias
* CS 201
* Final Project
* 11/20/2020
* Program: LineRoute.java
* Role: This class is used to maintain line route data for when a user generates a path from station to station
*/
//
package project;
import java.util.ArrayList;
public class LineRoute extends Station{
private ArrayList<Station> stations;
private String origin; //station name of user's starting station
private String destination; //station name of user's ending station
public String originLC; //the current line color the user starts on
public String destinationLC; //the line color the user ends on
private String stop;
public LineRoute(){ //constructor
this.stations = null;
this.origin = "";
this.destination = "";
this.stop = "";
}
public LineRoute(ArrayList<Station> stations,String fromLC, String toLC) { //constructor
this.stations = stations;
this.origin = stations.get(0).getName();
this.destination = stations.get(stations.size() - 1).getName();
this.originLC = fromLC;
this.destinationLC = toLC;
this.stop = "";
}
public ArrayList<Station> getStations() { //getter method
return stations;
}
public void setStations(ArrayList<Station> stations) { //setter method
this.stations = stations;
}
public String getOrigin() { //getter method
return origin;
}
public void setOrigin(String origin) { //setter method
this.origin = origin.toLowerCase();
}
public String getDestination() { //getter method
return destination;
}
public void setDestination(String destination) { //setter method
this.destination = destination.toLowerCase();
}
public void setOriginLC(String color) { //setter method
this.originLC = color;
}
public String getOriginLC() { //getter method
return originLC;
}
public void setDestinationLC(String color) { //setter method
this.destinationLC = color;
}
public String getDestinationLC() { //getter method
return destinationLC;
}
public String getStop() { //getter method
return stop;
}
public void setStop(String station) { //setter method
this.stop = station;
}
public String toString() {
if(!(stop.isEmpty())) { //if a stop is available, we print it. Otherwise, return "none" for stops.
return "Origin: " + getOrigin() + " (" + originLC.toUpperCase() +")" + "\nDestination: " + getDestination()+ " (" + destinationLC.toUpperCase() +")" + "\nStop: " + getStop();
}
return "Origin: " + getOrigin() + "\nDestination: " + getDestination() + " (" + destinationLC.toUpperCase() +")" + "\nStop: None";
}
public boolean equals(LineRoute l){
if(l.getOrigin().equals(origin) && l.getDestination().equals(destination) && l.getOriginLC().equals(originLC) && l.getDestinationLC().equals(destinationLC)) { //make sure to handle same names(different stations) in main class
return true;
}
return false;
}
@Override
public void takeRoute() {
if(originLC.equals(destinationLC)) {
System.out.println("\n===============================================");
System.out.println("Instructions from " + origin + " to " + destination);
System.out.println("===============================================");
System.out.println("\n[1] Get on the " + originLC + " line at " + origin + ".\n[2] Get off at " + destination + ".");
}
else if(originLC.equals("red") && destinationLC.equals("green") && stop.equals("State/Lake")){
System.out.println("\n===============================================");
System.out.println("Instructions from " + origin + " to " + destination + ".");
System.out.println("===============================================");
System.out.println("\n[1] Get on the " + originLC + " line at " + origin + ".\n[2] Transfer onto to the "
+ destinationLC + " line at " + stop + " via the pedway after getting off at Lake. \n[3] Finally, your last stop is " + destination + ".");
}
else if(originLC.equals("green") && destinationLC.equals("red") && stop.equals("State/Lake")){
System.out.println("\n===============================================");
System.out.println("Instructions from " + origin + " to " + destination + ".");
System.out.println("===============================================");
System.out.println("\n[1] Get on the " + originLC + " line at " + origin + ".\n[2] Transfer onto to the "
+ destinationLC + " line at Lake via the pedway after getting off at " + stop + ". \n[3] Finally, your last stop is " + destination + ".");
}
else if(originLC.equals("red") && stop.equals("State/Lake")) {
System.out.println("\n===============================================");
System.out.println("Instructions from " + origin + " to " + destination + ".");
System.out.println("===============================================");
System.out.println("\n[1] Get on the " + originLC + " line at " + origin + ".\n[2] Transfer onto to the "
+ destinationLC + " line at Lake by walking via the pedway to " + stop + ".\n[3] Finally, your last stop is " + destination + ".");
}
else if(originLC.equals("pink") && destinationLC.equals("red") && stop.equals("State/Lake") && origin.equals("Harold Washington Library")){
System.out.println("\n===============================================");
System.out.println("Instructions from " + origin + " to " + destination + ".");
System.out.println("===============================================");
System.out.println("\n[1] Get on the " + originLC + " line at " + origin + ".\n[2] Transfer onto to the "
+ destinationLC + " line at Lake via the pedway after getting off at " + stop + ".\n[3] Finally, your last stop is " + destination + ".");
}
else if(originLC.equals("brown") && destinationLC.equals("red") && stop.equals("State/Lake")){
System.out.println("\n===============================================");
System.out.println("Instructions from " + origin + " to " + destination + ".");
System.out.println("===============================================");
System.out.println("\n[1] Get on the " + originLC + " line at " + origin + ".\n[2] Transfer onto to the "
+ destinationLC + " line at Lake via the pedway after getting off at " + stop + ".\n[3] Finally, your last stop is " + destination + ".");
}
else {
System.out.println("\n===============================================");
System.out.println("Instructions for: " + origin + " to " + destination +".");
System.out.println("===============================================");
System.out.println("\n[1] Get on the " + originLC + " line at " + origin + ".\n[2] Transfer onto to the "
+ destinationLC + " line at " + stop + ".\n[3] Finally, your last stop is " + destination + ".");
}
}
}