SlideShare a Scribd company logo
1 of 11
Download to read offline
---BUS--
public class Bus {
String busIdentifier;
String driverName;
double averageSpeed;
BusRoute route;
ArrayList<Passenger> passengers;
BusStop currentStop;
public Bus(String busIdentifier, String driverName, double averageSpeed, BusRoute route) {
this.busIdentifier = busIdentifier;
this.driverName = driverName;
this.averageSpeed = averageSpeed;
this.route = route;
this.passengers = new ArrayList<Passenger>();
this.currentStop = route.firstStop;
}
public String getBusIdentifier() {
return busIdentifier;
}
public int getPassengers() {
return passengers.size();
}
public void letPassengersOn() {
ArrayList<Passenger> waitingPassengers = currentStop.getPassengers();
for (Passenger passenger : waitingPassengers) {
if (passengers.size() < 50) {
passengers.add(passenger);
} else {
break;
}
}
}
public void letPassengersOff() {
ArrayList<Passenger> passengersToRemove = new ArrayList<Passenger>();
for (Passenger passenger : passengers) {
if (passenger.getDestination() == currentStop) {
passengersToRemove.add(passenger);
}
}
passengers.removeAll(passengersToRemove);
}
public int moveToNextStop() {
BusStop nextStop = route.getNextStop(currentStop);
int minutesToNextStop = (int) (60 * BusRoute.getDistance(currentStop, nextStop) /
averageSpeed);
currentStop = nextStop;
return minutesToNextStop;
}
public void thankTheDriver() {
System.out.println("Thank you, " + driverName + ", for driving bus " + busIdentifier + "
today!");
}
public String toString() {
String output = "Bus " + busIdentifier + " (driver: " + driverName + ")n";
output += "Current stop: " + currentStop.getStopName() + "n";
output += "Passengers on board:n";
if (passengers.isEmpty()) {
output += "Nonen";
} else {
for (Passenger passenger : passengers) {
output += "- " + passenger + "n";
}
}
return output;
}
}
---METROROUTE--
package transit_manager;
public class MetroRoute {
int routeNumber;
String routeDescription;
MetroStation firstStop;
MetroStation lastStop;
public MetroRoute(int routeNumber, String routeDescription, MetroStation firstStop,
MetroStation lastStop) {
this.routeNumber = routeNumber;
this.routeDescription = routeDescription;
this.firstStop = firstStop;
this.lastStop = lastStop;
}
public double calculateDistance() {
return MetroStation.getDistance(firstStop, lastStop);
}
@Override
public String toString() {
return "Route " + routeNumber + ": " + routeDescription + " (" + firstStop.getName() + " - " +
lastStop.getName() + ")";
}
}
---TRANSITMANAGERRUNNER--
package transit_manager;
public class TransitManagerRunner
{
public static void main(String[] args)
{
System.out.println("BUS TESTING =============================n");
TestBuses();
System.out.println("METRO TESTING =============================n");
TestMetro();
}
public static void TestBuses()
{
// Create some bus stops
// Oakland stop, stop number 12342, at location (0,0)
BusStop stopA = new BusStop("Oakland", 12342, 0, 0);
BusStop stopB = new BusStop("Downtown", 87236, -2.3, 0.2);
BusStop stopC = new BusStop("Swissvale", 62341, 5.4, -0.4);
//Create some bus routes
BusRoute routeA = new BusRoute(61, "Connects Oakland with eastward residential areas.",
stopA, stopC);
BusRoute routeB = new BusRoute(71, "Connects Oakland with Downtown.", stopB, stopA);
//Use toStrings to describe these routes
System.out.println(routeA);
System.out.println(routeA.firstStop);
System.out.println(routeA.lastStop);
System.out.println();
System.out.println(routeB);
System.out.println(routeB.firstStop);
System.out.println(routeB.lastStop);
System.out.println("n================================n");
//Add a bus to each route
// Bus with identifier KLJF3, driver named Molly, average speed of 22 mph, on the 61 route
Bus busA = new Bus("KLJF3", "Molly", 22, routeA);
Bus busB = new Bus("LSHC6", "Keyang", 34, routeB);
//Let's learn more about these buses with our toString methods
System.out.println("Initial Bus Statusn");
System.out.println(busA);
System.out.println();
System.out.println(busB);
System.out.println("n================================n");
System.out.println("Gaining passengers and loading them onto buses...n");
// Lets wait for people to accumulate at our bus stops
stopA.gainPassengers();
stopB.gainPassengers();
stopC.gainPassengers();
//Check how many people are waiting at stopA
System.out.println("There are currently " + stopA.getPassengersWaiting() + " passengers waiting
at the " + stopA.getStopName() + " stop.");
//Load the buses
busA.letPassengersOn();
busB.letPassengersOn();
System.out.println("nPassengers have loaded on the buses.n");
//Check on bus A now that it has gained passengers
System.out.println(busA);
//And check to make sure no one is left at the stop
System.out.println("There are currently " + stopA.getPassengersWaiting() + " passengers waiting
at the " + stopA.getStopName() + " stop.");
System.out.println("n================================n");
System.out.println("The buses will drive to their next stops!n");
System.out.println("Bus " + busA.getBusIdentifier() + " took " + busA.moveToNextStop() + "
minutes to reach " + busA.currentStop.getStopName());
System.out.println("Bus " + busB.getBusIdentifier() + " took " + busB.moveToNextStop() + "
minutes to reach " + busB.currentStop.getStopName());
System.out.println("n================================n");
System.out.println("Letting bus A cycle aroundn");
//Let off Bus A's passengers and let on new ones
busA.letPassengersOff();
busA.letPassengersOn();
System.out.println(busA);
//Move one more time
System.out.println("Bus " + busA.getBusIdentifier() + " took " + busA.moveToNextStop() + "
minutes to reach " + busA.currentStop.getStopName());
System.out.println("n================================n");
//Don't forget to thank the bus drivers!
busA.thankTheDriver();
busB.thankTheDriver();
System.out.println();
}
public static void TestMetro()
{
//Create some Metro Stations
//Downtown stop, stop number 41232, at location (-2.3, 0.2)
MetroStation stationA = new MetroStation("Downtown", 41232, -2.3, 0.2);
MetroStation stationB = new MetroStation("Station Square", 92319, -2.2, -0.8);
MetroStation stationC = new MetroStation("North Shore", 12091, -3.2, 1.1);
//Create some Metro Routes
MetroRoute routeA = new MetroRoute(102, "Connects Downtown and Station Square",
stationA, stationB);
MetroRoute routeB = new MetroRoute(103, "Connects Downtown and the North Shore",
stationC, stationA);
//Use toStrings to describe these routes
System.out.println(routeA);
System.out.println(routeA.firstStop);
System.out.println(routeA.lastStop);
System.out.println();
System.out.println(routeB);
System.out.println(routeB.firstStop);
System.out.println(routeB.lastStop);
System.out.println("n================================n");
//Add a Train to each route
// Train with identifier IOPS2, conductor named Eli, average speed of 20 mph, 3 train cars, on
the 102 route
Train trainA = new Train("IOPS2", "Eli", 20, 3, routeA);
Train trainB = new Train("LSHC6", "Lydia", 35, 5, routeB);
//Let's learn more about these trains with our toString methods
System.out.println("Initial Train Statusn");
System.out.println(trainA);
System.out.println();
System.out.println(trainB);
System.out.println("n================================n");
System.out.println("Gaining passengers and loading them onto trains...n");
// Lets wait for people to accumulate at our train stations
stationA.gainPassengers();
stationB.gainPassengers();
stationC.gainPassengers();
//Check how many people are waiting at station A
System.out.println("There are currently " + stationA.getPassengersWaiting() + " passengers
waiting at the " + stationA.getStationName() + " station.");
//Load the trains
trainA.letPassengersOn();
trainB.letPassengersOn();
System.out.println("nPassengers have loaded on the trains.n");
//Check on train A now that it has gained passengers
System.out.println(trainA);
//And check to make sure folks have loaded
System.out.println("There are currently " + stationA.getPassengersWaiting() + " passengers
waiting at the " + stationA.getStationName() + " stop.");
System.out.println("n================================n");
System.out.println("The trains will ride to their next stops!n");
System.out.println("Train " + trainA.getTrainIdentifier() + " took " +
trainA.moveToNextStation() + " minutes to reach " + trainA.currentStation.getStationName());
System.out.println("Bus " + trainB.getTrainIdentifier() + " took " + trainB.moveToNextStation()
+ " minutes to reach " + trainB.currentStation.getStationName());
System.out.println("n================================n");
System.out.println("Letting Train A cycle aroundn");
//Let off Train A's passengers and let on new ones
trainA.letPassengersOff();
trainA.letPassengersOn();
System.out.println(trainA);
//Move one more time
System.out.println("Bus " + trainA.getTrainIdentifier() + " took " + trainA.moveToNextStation()
+ " minutes to reach " + trainA.currentStation.getStationName());
System.out.println("n================================n");
//Don't forget to thank the conductors!
trainA.thankTheConductor();
trainB.thankTheConductor();
System.out.println();
}
}
Bus Route #61: Connects 0akland with eastward residential areas. Stop #12342: 0akland 0
passengers waiting. Stop #62341: Swissvale 0 passengers waiting. Bus Route #71: Connects
0akland with Downtown. Stop #87236: Downtown 0 passengers waiting. Stop #12342: 0akland
0 passengers waiting. Initial Bus Status Bus KLJF3 (Molly) traveling on route #61 Currently
stopped at Oakland 0 seats taken out of 30 Bus LSHC6 (Keyang) traveling on route #71
Currently stopped at Downtown 0 seats taken out of 30 Gaining passengers and loading them
onto buses... There are currently 10 passengers waiting at the 0akland stop. Passengers have
loaded on the buses. Bus KLJF3 (Molly) traveling on route #61 Currently stopped at Oakland 10
seats taken out of 30 There are currently 0 passengers waiting at the 0akland stop. The buses will
drive to their next stops! Bus KLJF3 took 14.767621495288237 minutes to reach Swissvale Bus
LSHC6 took 4.074139899040656 minutes to reach 0akland Letting bus A cycle around Bus
KLJF3 (Molly) traveling on route #61 Currently stopped at Swissvale 25 seats taken out of 30
Bus KLJF3 took 14.767621495288237 minutes to reach 0akland Thanks Molly! Thanks Keyang!
Metro Route #102: Connects Downtown and Station Square Station #41232: Downtown 0
passengers waiting. Station #92319: Station Square 0 passengers waiting. Metro Route #103:
Connects Downtown and the North Shore Station #12091: North Shore 0 passengers waiting.
Station #41232: Downtown 0 passengers waiting. Initial Train Status Train IOPS2 (Eli)
traveling on route #102 Currently stopped at Downtown 0 seats taken out of 360 Train LSHC6
(Lydia) traveling on route #103 Currently stopped at North Shore 0 seats taken out of 600
Gaining passengers and loading them onto trains... There are currently 28 passengers waiting at
the Downtown station. Passengers have loaded on the trains. Train IOPS2 (Eli) traveling on route
#102 Currently stopped at Downtown 28 seats taken out of 360 There are currently 0 passengers
waiting at the Downtown stop. The trains will ride to their next stops! Train IOPS2 took
3.0149626863362666 minutes to reach Station Square Bus LSHC6 took 2.181929496232776
minutes to reach Downtown Letting Train A cycle around Train IOPS2 (Eli) traveling on route
#102 Currently stopped at Station Square 12 seats taken out of 360 Bus IOPS2 took
3.0149626863362666 minutes to reach Downtown Thanks Eli! Thanks Lydia!

More Related Content

Similar to ---BUS-- public class Bus { String busIdentifier- String driverName- d.pdf

Shapes and calculate (area and contour) / C++ oop concept
Shapes and calculate (area and contour) / C++ oop conceptShapes and calculate (area and contour) / C++ oop concept
Shapes and calculate (area and contour) / C++ oop conceptkinan keshkeh
 
Project 3–Advanced Taxi SystemObjectiveTo gain experience and prac.pdf
Project 3–Advanced Taxi SystemObjectiveTo gain experience and prac.pdfProject 3–Advanced Taxi SystemObjectiveTo gain experience and prac.pdf
Project 3–Advanced Taxi SystemObjectiveTo gain experience and prac.pdfaminbijal86
 
Geo CO - RTD Denver
Geo CO - RTD DenverGeo CO - RTD Denver
Geo CO - RTD DenverMike Giddens
 
Nodejs do teste de unidade ao de integração
Nodejs  do teste de unidade ao de integraçãoNodejs  do teste de unidade ao de integração
Nodejs do teste de unidade ao de integraçãoVinícius Pretto da Silva
 
package lab7; import java.util.Scanner; Sammy Student, Program.pdf
package lab7; import java.util.Scanner; Sammy Student, Program.pdfpackage lab7; import java.util.Scanner; Sammy Student, Program.pdf
package lab7; import java.util.Scanner; Sammy Student, Program.pdfinfoeyecare
 
please help with java questionsJAVA CODEplease check my code and.pdf
please help with java questionsJAVA CODEplease check my code and.pdfplease help with java questionsJAVA CODEplease check my code and.pdf
please help with java questionsJAVA CODEplease check my code and.pdfarishmarketing21
 
Marble Testing RxJS streams
Marble Testing RxJS streamsMarble Testing RxJS streams
Marble Testing RxJS streamsIlia Idakiev
 
Write CC++ a program that inputs a weighted undirected graph and fi.pdf
Write CC++ a program that inputs a weighted undirected graph and fi.pdfWrite CC++ a program that inputs a weighted undirected graph and fi.pdf
Write CC++ a program that inputs a weighted undirected graph and fi.pdf4babies2010
 
import java-util-ArrayList- public class Bus { private String na.pdf
import java-util-ArrayList-   public class Bus {     private String na.pdfimport java-util-ArrayList-   public class Bus {     private String na.pdf
import java-util-ArrayList- public class Bus { private String na.pdfGordonF2XPatersonh
 
The Test File- The code- #include -iostream- #include -vector- #includ.docx
The Test File- The code- #include -iostream- #include -vector- #includ.docxThe Test File- The code- #include -iostream- #include -vector- #includ.docx
The Test File- The code- #include -iostream- #include -vector- #includ.docxAustinIKkNorthy
 

Similar to ---BUS-- public class Bus { String busIdentifier- String driverName- d.pdf (16)

Shapes and calculate (area and contour) / C++ oop concept
Shapes and calculate (area and contour) / C++ oop conceptShapes and calculate (area and contour) / C++ oop concept
Shapes and calculate (area and contour) / C++ oop concept
 
Project 3–Advanced Taxi SystemObjectiveTo gain experience and prac.pdf
Project 3–Advanced Taxi SystemObjectiveTo gain experience and prac.pdfProject 3–Advanced Taxi SystemObjectiveTo gain experience and prac.pdf
Project 3–Advanced Taxi SystemObjectiveTo gain experience and prac.pdf
 
Geo CO - RTD Denver
Geo CO - RTD DenverGeo CO - RTD Denver
Geo CO - RTD Denver
 
Nodejs do teste de unidade ao de integração
Nodejs  do teste de unidade ao de integraçãoNodejs  do teste de unidade ao de integração
Nodejs do teste de unidade ao de integração
 
package lab7; import java.util.Scanner; Sammy Student, Program.pdf
package lab7; import java.util.Scanner; Sammy Student, Program.pdfpackage lab7; import java.util.Scanner; Sammy Student, Program.pdf
package lab7; import java.util.Scanner; Sammy Student, Program.pdf
 
please help with java questionsJAVA CODEplease check my code and.pdf
please help with java questionsJAVA CODEplease check my code and.pdfplease help with java questionsJAVA CODEplease check my code and.pdf
please help with java questionsJAVA CODEplease check my code and.pdf
 
Evolving Tests
Evolving TestsEvolving Tests
Evolving Tests
 
week-3x
week-3xweek-3x
week-3x
 
Marble Testing RxJS streams
Marble Testing RxJS streamsMarble Testing RxJS streams
Marble Testing RxJS streams
 
Write CC++ a program that inputs a weighted undirected graph and fi.pdf
Write CC++ a program that inputs a weighted undirected graph and fi.pdfWrite CC++ a program that inputs a weighted undirected graph and fi.pdf
Write CC++ a program that inputs a weighted undirected graph and fi.pdf
 
import java-util-ArrayList- public class Bus { private String na.pdf
import java-util-ArrayList-   public class Bus {     private String na.pdfimport java-util-ArrayList-   public class Bus {     private String na.pdf
import java-util-ArrayList- public class Bus { private String na.pdf
 
Aimaf
AimafAimaf
Aimaf
 
Spark - Citi Bike NYC
Spark - Citi Bike NYCSpark - Citi Bike NYC
Spark - Citi Bike NYC
 
Akka http 2
Akka http 2Akka http 2
Akka http 2
 
The Test File- The code- #include -iostream- #include -vector- #includ.docx
The Test File- The code- #include -iostream- #include -vector- #includ.docxThe Test File- The code- #include -iostream- #include -vector- #includ.docx
The Test File- The code- #include -iostream- #include -vector- #includ.docx
 
Arrays in php
Arrays in phpArrays in php
Arrays in php
 

More from AdrianEBJKingr

1- Answer the following characteristics for Chytridiomycota Fungi- A-.pdf
1- Answer the following characteristics for Chytridiomycota Fungi- A-.pdf1- Answer the following characteristics for Chytridiomycota Fungi- A-.pdf
1- Answer the following characteristics for Chytridiomycota Fungi- A-.pdfAdrianEBJKingr
 
1- A TIPS has a coupon of 7-- paid semiannually- The current rate of i.pdf
1- A TIPS has a coupon of 7-- paid semiannually- The current rate of i.pdf1- A TIPS has a coupon of 7-- paid semiannually- The current rate of i.pdf
1- A TIPS has a coupon of 7-- paid semiannually- The current rate of i.pdfAdrianEBJKingr
 
1- A General Right to Privacy was written explicitly into the US Const.pdf
1- A General Right to Privacy was written explicitly into the US Const.pdf1- A General Right to Privacy was written explicitly into the US Const.pdf
1- A General Right to Privacy was written explicitly into the US Const.pdfAdrianEBJKingr
 
1- A business has the following information for the year- Determine th.pdf
1- A business has the following information for the year- Determine th.pdf1- A business has the following information for the year- Determine th.pdf
1- A business has the following information for the year- Determine th.pdfAdrianEBJKingr
 
1- -8 points- Write a MIPS code to compute the factorial of a positive.pdf
1- -8 points- Write a MIPS code to compute the factorial of a positive.pdf1- -8 points- Write a MIPS code to compute the factorial of a positive.pdf
1- -8 points- Write a MIPS code to compute the factorial of a positive.pdfAdrianEBJKingr
 
1- (Aggregates) Consider an economy that is in below full employment e.pdf
1- (Aggregates) Consider an economy that is in below full employment e.pdf1- (Aggregates) Consider an economy that is in below full employment e.pdf
1- (Aggregates) Consider an economy that is in below full employment e.pdfAdrianEBJKingr
 
1- (3 polats) O Suppose that A add B are ladepedbet ewnts- Furthemore-.pdf
1- (3 polats) O Suppose that A add B are ladepedbet ewnts- Furthemore-.pdf1- (3 polats) O Suppose that A add B are ladepedbet ewnts- Furthemore-.pdf
1- (3 polats) O Suppose that A add B are ladepedbet ewnts- Furthemore-.pdfAdrianEBJKingr
 
-The following information applies to the questions displayed below- O.pdf
-The following information applies to the questions displayed below- O.pdf-The following information applies to the questions displayed below- O.pdf
-The following information applies to the questions displayed below- O.pdfAdrianEBJKingr
 
-NYP-- New York Paper Co-- is using its financial results for August 2.pdf
-NYP-- New York Paper Co-- is using its financial results for August 2.pdf-NYP-- New York Paper Co-- is using its financial results for August 2.pdf
-NYP-- New York Paper Co-- is using its financial results for August 2.pdfAdrianEBJKingr
 
-Java lang- Q3 (10)- A program creates a queue- The program takes arra.pdf
-Java lang- Q3 (10)- A program creates a queue- The program takes arra.pdf-Java lang- Q3 (10)- A program creates a queue- The program takes arra.pdf
-Java lang- Q3 (10)- A program creates a queue- The program takes arra.pdfAdrianEBJKingr
 
-2-Cyanide is a highly fast-acting poison- In fact- it was developed a.pdf
-2-Cyanide is a highly fast-acting poison- In fact- it was developed a.pdf-2-Cyanide is a highly fast-acting poison- In fact- it was developed a.pdf
-2-Cyanide is a highly fast-acting poison- In fact- it was developed a.pdfAdrianEBJKingr
 
-begin{tabular}{l-l} cHALlenge -- ACriviry -end{tabular} 4-3-1- Confid.pdf
-begin{tabular}{l-l} cHALlenge -- ACriviry -end{tabular} 4-3-1- Confid.pdf-begin{tabular}{l-l} cHALlenge -- ACriviry -end{tabular} 4-3-1- Confid.pdf
-begin{tabular}{l-l} cHALlenge -- ACriviry -end{tabular} 4-3-1- Confid.pdfAdrianEBJKingr
 
-10 points- For each of the Regular Expression- draw FA recognizing th.pdf
-10 points- For each of the Regular Expression- draw FA recognizing th.pdf-10 points- For each of the Regular Expression- draw FA recognizing th.pdf
-10 points- For each of the Regular Expression- draw FA recognizing th.pdfAdrianEBJKingr
 
--What is wrong with this C++ program- -- # include iostream using nam.pdf
--What is wrong with this C++ program- -- # include iostream using nam.pdf--What is wrong with this C++ program- -- # include iostream using nam.pdf
--What is wrong with this C++ program- -- # include iostream using nam.pdfAdrianEBJKingr
 
-10 points- Construct minimized DFA accepting language represented by.pdf
-10 points- Construct minimized DFA accepting language represented by.pdf-10 points- Construct minimized DFA accepting language represented by.pdf
-10 points- Construct minimized DFA accepting language represented by.pdfAdrianEBJKingr
 
--INSTRUCTION- --It helps to first create if-then-else structure to fi.pdf
--INSTRUCTION- --It helps to first create if-then-else structure to fi.pdf--INSTRUCTION- --It helps to first create if-then-else structure to fi.pdf
--INSTRUCTION- --It helps to first create if-then-else structure to fi.pdfAdrianEBJKingr
 
--kindly help---Explain what happens when the PUSHA instruction execut.pdf
--kindly help---Explain what happens when the PUSHA instruction execut.pdf--kindly help---Explain what happens when the PUSHA instruction execut.pdf
--kindly help---Explain what happens when the PUSHA instruction execut.pdfAdrianEBJKingr
 
1)What is the most important benefit you believe students get from the.pdf
1)What is the most important benefit you believe students get from the.pdf1)What is the most important benefit you believe students get from the.pdf
1)What is the most important benefit you believe students get from the.pdfAdrianEBJKingr
 
1) Was Solyndra a profitable company- 2) What was Solyndra's business.pdf
1) Was Solyndra a profitable company- 2) What was Solyndra's business.pdf1) Was Solyndra a profitable company- 2) What was Solyndra's business.pdf
1) Was Solyndra a profitable company- 2) What was Solyndra's business.pdfAdrianEBJKingr
 

More from AdrianEBJKingr (20)

1- Answer the following characteristics for Chytridiomycota Fungi- A-.pdf
1- Answer the following characteristics for Chytridiomycota Fungi- A-.pdf1- Answer the following characteristics for Chytridiomycota Fungi- A-.pdf
1- Answer the following characteristics for Chytridiomycota Fungi- A-.pdf
 
1- A TIPS has a coupon of 7-- paid semiannually- The current rate of i.pdf
1- A TIPS has a coupon of 7-- paid semiannually- The current rate of i.pdf1- A TIPS has a coupon of 7-- paid semiannually- The current rate of i.pdf
1- A TIPS has a coupon of 7-- paid semiannually- The current rate of i.pdf
 
1- A General Right to Privacy was written explicitly into the US Const.pdf
1- A General Right to Privacy was written explicitly into the US Const.pdf1- A General Right to Privacy was written explicitly into the US Const.pdf
1- A General Right to Privacy was written explicitly into the US Const.pdf
 
1- A business has the following information for the year- Determine th.pdf
1- A business has the following information for the year- Determine th.pdf1- A business has the following information for the year- Determine th.pdf
1- A business has the following information for the year- Determine th.pdf
 
1- -8 points- Write a MIPS code to compute the factorial of a positive.pdf
1- -8 points- Write a MIPS code to compute the factorial of a positive.pdf1- -8 points- Write a MIPS code to compute the factorial of a positive.pdf
1- -8 points- Write a MIPS code to compute the factorial of a positive.pdf
 
1- (Aggregates) Consider an economy that is in below full employment e.pdf
1- (Aggregates) Consider an economy that is in below full employment e.pdf1- (Aggregates) Consider an economy that is in below full employment e.pdf
1- (Aggregates) Consider an economy that is in below full employment e.pdf
 
1- (3 polats) O Suppose that A add B are ladepedbet ewnts- Furthemore-.pdf
1- (3 polats) O Suppose that A add B are ladepedbet ewnts- Furthemore-.pdf1- (3 polats) O Suppose that A add B are ladepedbet ewnts- Furthemore-.pdf
1- (3 polats) O Suppose that A add B are ladepedbet ewnts- Furthemore-.pdf
 
-The following information applies to the questions displayed below- O.pdf
-The following information applies to the questions displayed below- O.pdf-The following information applies to the questions displayed below- O.pdf
-The following information applies to the questions displayed below- O.pdf
 
-NYP-- New York Paper Co-- is using its financial results for August 2.pdf
-NYP-- New York Paper Co-- is using its financial results for August 2.pdf-NYP-- New York Paper Co-- is using its financial results for August 2.pdf
-NYP-- New York Paper Co-- is using its financial results for August 2.pdf
 
-Java lang- Q3 (10)- A program creates a queue- The program takes arra.pdf
-Java lang- Q3 (10)- A program creates a queue- The program takes arra.pdf-Java lang- Q3 (10)- A program creates a queue- The program takes arra.pdf
-Java lang- Q3 (10)- A program creates a queue- The program takes arra.pdf
 
-2-Cyanide is a highly fast-acting poison- In fact- it was developed a.pdf
-2-Cyanide is a highly fast-acting poison- In fact- it was developed a.pdf-2-Cyanide is a highly fast-acting poison- In fact- it was developed a.pdf
-2-Cyanide is a highly fast-acting poison- In fact- it was developed a.pdf
 
-23-.pdf
-23-.pdf-23-.pdf
-23-.pdf
 
-begin{tabular}{l-l} cHALlenge -- ACriviry -end{tabular} 4-3-1- Confid.pdf
-begin{tabular}{l-l} cHALlenge -- ACriviry -end{tabular} 4-3-1- Confid.pdf-begin{tabular}{l-l} cHALlenge -- ACriviry -end{tabular} 4-3-1- Confid.pdf
-begin{tabular}{l-l} cHALlenge -- ACriviry -end{tabular} 4-3-1- Confid.pdf
 
-10 points- For each of the Regular Expression- draw FA recognizing th.pdf
-10 points- For each of the Regular Expression- draw FA recognizing th.pdf-10 points- For each of the Regular Expression- draw FA recognizing th.pdf
-10 points- For each of the Regular Expression- draw FA recognizing th.pdf
 
--What is wrong with this C++ program- -- # include iostream using nam.pdf
--What is wrong with this C++ program- -- # include iostream using nam.pdf--What is wrong with this C++ program- -- # include iostream using nam.pdf
--What is wrong with this C++ program- -- # include iostream using nam.pdf
 
-10 points- Construct minimized DFA accepting language represented by.pdf
-10 points- Construct minimized DFA accepting language represented by.pdf-10 points- Construct minimized DFA accepting language represented by.pdf
-10 points- Construct minimized DFA accepting language represented by.pdf
 
--INSTRUCTION- --It helps to first create if-then-else structure to fi.pdf
--INSTRUCTION- --It helps to first create if-then-else structure to fi.pdf--INSTRUCTION- --It helps to first create if-then-else structure to fi.pdf
--INSTRUCTION- --It helps to first create if-then-else structure to fi.pdf
 
--kindly help---Explain what happens when the PUSHA instruction execut.pdf
--kindly help---Explain what happens when the PUSHA instruction execut.pdf--kindly help---Explain what happens when the PUSHA instruction execut.pdf
--kindly help---Explain what happens when the PUSHA instruction execut.pdf
 
1)What is the most important benefit you believe students get from the.pdf
1)What is the most important benefit you believe students get from the.pdf1)What is the most important benefit you believe students get from the.pdf
1)What is the most important benefit you believe students get from the.pdf
 
1) Was Solyndra a profitable company- 2) What was Solyndra's business.pdf
1) Was Solyndra a profitable company- 2) What was Solyndra's business.pdf1) Was Solyndra a profitable company- 2) What was Solyndra's business.pdf
1) Was Solyndra a profitable company- 2) What was Solyndra's business.pdf
 

Recently uploaded

microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introductionMaksud Ahmed
 
Separation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesSeparation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesFatimaKhan178732
 
Crayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon ACrayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon AUnboundStockton
 
Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991
Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991
Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991RKavithamani
 
Alper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentAlper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentInMediaRes1
 
Solving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxSolving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxOH TEIK BIN
 
Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxpboyjonauth
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Sapana Sha
 
Mastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionMastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionSafetyChain Software
 
Presiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsPresiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsanshu789521
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformChameera Dedduwage
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptxVS Mahajan Coaching Centre
 
Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3JemimahLaneBuaron
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityGeoBlogs
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfsanyamsingh5019
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...EduSkills OECD
 
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxSayali Powar
 

Recently uploaded (20)

microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introduction
 
Separation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesSeparation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and Actinides
 
Crayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon ACrayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon A
 
Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991
Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991
Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991
 
Alper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentAlper Gobel In Media Res Media Component
Alper Gobel In Media Res Media Component
 
Solving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxSolving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptx
 
Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptx
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
 
Mastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionMastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory Inspection
 
Model Call Girl in Bikash Puri Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Bikash Puri  Delhi reach out to us at 🔝9953056974🔝Model Call Girl in Bikash Puri  Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Bikash Puri Delhi reach out to us at 🔝9953056974🔝
 
Staff of Color (SOC) Retention Efforts DDSD
Staff of Color (SOC) Retention Efforts DDSDStaff of Color (SOC) Retention Efforts DDSD
Staff of Color (SOC) Retention Efforts DDSD
 
Presiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsPresiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha elections
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy Reform
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
 
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
 
Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activity
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdf
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
 
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
 

---BUS-- public class Bus { String busIdentifier- String driverName- d.pdf

  • 1. ---BUS-- public class Bus { String busIdentifier; String driverName; double averageSpeed; BusRoute route; ArrayList<Passenger> passengers; BusStop currentStop; public Bus(String busIdentifier, String driverName, double averageSpeed, BusRoute route) { this.busIdentifier = busIdentifier; this.driverName = driverName; this.averageSpeed = averageSpeed; this.route = route; this.passengers = new ArrayList<Passenger>(); this.currentStop = route.firstStop; } public String getBusIdentifier() { return busIdentifier; } public int getPassengers() { return passengers.size(); } public void letPassengersOn() {
  • 2. ArrayList<Passenger> waitingPassengers = currentStop.getPassengers(); for (Passenger passenger : waitingPassengers) { if (passengers.size() < 50) { passengers.add(passenger); } else { break; } } } public void letPassengersOff() { ArrayList<Passenger> passengersToRemove = new ArrayList<Passenger>(); for (Passenger passenger : passengers) { if (passenger.getDestination() == currentStop) { passengersToRemove.add(passenger); } } passengers.removeAll(passengersToRemove); } public int moveToNextStop() { BusStop nextStop = route.getNextStop(currentStop); int minutesToNextStop = (int) (60 * BusRoute.getDistance(currentStop, nextStop) / averageSpeed); currentStop = nextStop; return minutesToNextStop;
  • 3. } public void thankTheDriver() { System.out.println("Thank you, " + driverName + ", for driving bus " + busIdentifier + " today!"); } public String toString() { String output = "Bus " + busIdentifier + " (driver: " + driverName + ")n"; output += "Current stop: " + currentStop.getStopName() + "n"; output += "Passengers on board:n"; if (passengers.isEmpty()) { output += "Nonen"; } else { for (Passenger passenger : passengers) { output += "- " + passenger + "n"; } } return output; } } ---METROROUTE-- package transit_manager; public class MetroRoute { int routeNumber; String routeDescription;
  • 4. MetroStation firstStop; MetroStation lastStop; public MetroRoute(int routeNumber, String routeDescription, MetroStation firstStop, MetroStation lastStop) { this.routeNumber = routeNumber; this.routeDescription = routeDescription; this.firstStop = firstStop; this.lastStop = lastStop; } public double calculateDistance() { return MetroStation.getDistance(firstStop, lastStop); } @Override public String toString() { return "Route " + routeNumber + ": " + routeDescription + " (" + firstStop.getName() + " - " + lastStop.getName() + ")"; } } ---TRANSITMANAGERRUNNER-- package transit_manager; public class TransitManagerRunner { public static void main(String[] args) {
  • 5. System.out.println("BUS TESTING =============================n"); TestBuses(); System.out.println("METRO TESTING =============================n"); TestMetro(); } public static void TestBuses() { // Create some bus stops // Oakland stop, stop number 12342, at location (0,0) BusStop stopA = new BusStop("Oakland", 12342, 0, 0); BusStop stopB = new BusStop("Downtown", 87236, -2.3, 0.2); BusStop stopC = new BusStop("Swissvale", 62341, 5.4, -0.4); //Create some bus routes BusRoute routeA = new BusRoute(61, "Connects Oakland with eastward residential areas.", stopA, stopC); BusRoute routeB = new BusRoute(71, "Connects Oakland with Downtown.", stopB, stopA); //Use toStrings to describe these routes System.out.println(routeA); System.out.println(routeA.firstStop); System.out.println(routeA.lastStop); System.out.println(); System.out.println(routeB); System.out.println(routeB.firstStop); System.out.println(routeB.lastStop);
  • 6. System.out.println("n================================n"); //Add a bus to each route // Bus with identifier KLJF3, driver named Molly, average speed of 22 mph, on the 61 route Bus busA = new Bus("KLJF3", "Molly", 22, routeA); Bus busB = new Bus("LSHC6", "Keyang", 34, routeB); //Let's learn more about these buses with our toString methods System.out.println("Initial Bus Statusn"); System.out.println(busA); System.out.println(); System.out.println(busB); System.out.println("n================================n"); System.out.println("Gaining passengers and loading them onto buses...n"); // Lets wait for people to accumulate at our bus stops stopA.gainPassengers(); stopB.gainPassengers(); stopC.gainPassengers(); //Check how many people are waiting at stopA System.out.println("There are currently " + stopA.getPassengersWaiting() + " passengers waiting at the " + stopA.getStopName() + " stop."); //Load the buses busA.letPassengersOn(); busB.letPassengersOn(); System.out.println("nPassengers have loaded on the buses.n"); //Check on bus A now that it has gained passengers
  • 7. System.out.println(busA); //And check to make sure no one is left at the stop System.out.println("There are currently " + stopA.getPassengersWaiting() + " passengers waiting at the " + stopA.getStopName() + " stop."); System.out.println("n================================n"); System.out.println("The buses will drive to their next stops!n"); System.out.println("Bus " + busA.getBusIdentifier() + " took " + busA.moveToNextStop() + " minutes to reach " + busA.currentStop.getStopName()); System.out.println("Bus " + busB.getBusIdentifier() + " took " + busB.moveToNextStop() + " minutes to reach " + busB.currentStop.getStopName()); System.out.println("n================================n"); System.out.println("Letting bus A cycle aroundn"); //Let off Bus A's passengers and let on new ones busA.letPassengersOff(); busA.letPassengersOn(); System.out.println(busA); //Move one more time System.out.println("Bus " + busA.getBusIdentifier() + " took " + busA.moveToNextStop() + " minutes to reach " + busA.currentStop.getStopName()); System.out.println("n================================n"); //Don't forget to thank the bus drivers! busA.thankTheDriver(); busB.thankTheDriver(); System.out.println(); }
  • 8. public static void TestMetro() { //Create some Metro Stations //Downtown stop, stop number 41232, at location (-2.3, 0.2) MetroStation stationA = new MetroStation("Downtown", 41232, -2.3, 0.2); MetroStation stationB = new MetroStation("Station Square", 92319, -2.2, -0.8); MetroStation stationC = new MetroStation("North Shore", 12091, -3.2, 1.1); //Create some Metro Routes MetroRoute routeA = new MetroRoute(102, "Connects Downtown and Station Square", stationA, stationB); MetroRoute routeB = new MetroRoute(103, "Connects Downtown and the North Shore", stationC, stationA); //Use toStrings to describe these routes System.out.println(routeA); System.out.println(routeA.firstStop); System.out.println(routeA.lastStop); System.out.println(); System.out.println(routeB); System.out.println(routeB.firstStop); System.out.println(routeB.lastStop); System.out.println("n================================n"); //Add a Train to each route // Train with identifier IOPS2, conductor named Eli, average speed of 20 mph, 3 train cars, on the 102 route Train trainA = new Train("IOPS2", "Eli", 20, 3, routeA);
  • 9. Train trainB = new Train("LSHC6", "Lydia", 35, 5, routeB); //Let's learn more about these trains with our toString methods System.out.println("Initial Train Statusn"); System.out.println(trainA); System.out.println(); System.out.println(trainB); System.out.println("n================================n"); System.out.println("Gaining passengers and loading them onto trains...n"); // Lets wait for people to accumulate at our train stations stationA.gainPassengers(); stationB.gainPassengers(); stationC.gainPassengers(); //Check how many people are waiting at station A System.out.println("There are currently " + stationA.getPassengersWaiting() + " passengers waiting at the " + stationA.getStationName() + " station."); //Load the trains trainA.letPassengersOn(); trainB.letPassengersOn(); System.out.println("nPassengers have loaded on the trains.n"); //Check on train A now that it has gained passengers System.out.println(trainA); //And check to make sure folks have loaded System.out.println("There are currently " + stationA.getPassengersWaiting() + " passengers waiting at the " + stationA.getStationName() + " stop.");
  • 10. System.out.println("n================================n"); System.out.println("The trains will ride to their next stops!n"); System.out.println("Train " + trainA.getTrainIdentifier() + " took " + trainA.moveToNextStation() + " minutes to reach " + trainA.currentStation.getStationName()); System.out.println("Bus " + trainB.getTrainIdentifier() + " took " + trainB.moveToNextStation() + " minutes to reach " + trainB.currentStation.getStationName()); System.out.println("n================================n"); System.out.println("Letting Train A cycle aroundn"); //Let off Train A's passengers and let on new ones trainA.letPassengersOff(); trainA.letPassengersOn(); System.out.println(trainA); //Move one more time System.out.println("Bus " + trainA.getTrainIdentifier() + " took " + trainA.moveToNextStation() + " minutes to reach " + trainA.currentStation.getStationName()); System.out.println("n================================n"); //Don't forget to thank the conductors! trainA.thankTheConductor(); trainB.thankTheConductor(); System.out.println(); } } Bus Route #61: Connects 0akland with eastward residential areas. Stop #12342: 0akland 0 passengers waiting. Stop #62341: Swissvale 0 passengers waiting. Bus Route #71: Connects 0akland with Downtown. Stop #87236: Downtown 0 passengers waiting. Stop #12342: 0akland 0 passengers waiting. Initial Bus Status Bus KLJF3 (Molly) traveling on route #61 Currently stopped at Oakland 0 seats taken out of 30 Bus LSHC6 (Keyang) traveling on route #71
  • 11. Currently stopped at Downtown 0 seats taken out of 30 Gaining passengers and loading them onto buses... There are currently 10 passengers waiting at the 0akland stop. Passengers have loaded on the buses. Bus KLJF3 (Molly) traveling on route #61 Currently stopped at Oakland 10 seats taken out of 30 There are currently 0 passengers waiting at the 0akland stop. The buses will drive to their next stops! Bus KLJF3 took 14.767621495288237 minutes to reach Swissvale Bus LSHC6 took 4.074139899040656 minutes to reach 0akland Letting bus A cycle around Bus KLJF3 (Molly) traveling on route #61 Currently stopped at Swissvale 25 seats taken out of 30 Bus KLJF3 took 14.767621495288237 minutes to reach 0akland Thanks Molly! Thanks Keyang! Metro Route #102: Connects Downtown and Station Square Station #41232: Downtown 0 passengers waiting. Station #92319: Station Square 0 passengers waiting. Metro Route #103: Connects Downtown and the North Shore Station #12091: North Shore 0 passengers waiting. Station #41232: Downtown 0 passengers waiting. Initial Train Status Train IOPS2 (Eli) traveling on route #102 Currently stopped at Downtown 0 seats taken out of 360 Train LSHC6 (Lydia) traveling on route #103 Currently stopped at North Shore 0 seats taken out of 600 Gaining passengers and loading them onto trains... There are currently 28 passengers waiting at the Downtown station. Passengers have loaded on the trains. Train IOPS2 (Eli) traveling on route #102 Currently stopped at Downtown 28 seats taken out of 360 There are currently 0 passengers waiting at the Downtown stop. The trains will ride to their next stops! Train IOPS2 took 3.0149626863362666 minutes to reach Station Square Bus LSHC6 took 2.181929496232776 minutes to reach Downtown Letting Train A cycle around Train IOPS2 (Eli) traveling on route #102 Currently stopped at Station Square 12 seats taken out of 360 Bus IOPS2 took 3.0149626863362666 minutes to reach Downtown Thanks Eli! Thanks Lydia!