SlideShare uma empresa Scribd logo
1 de 9
Baixar para ler offline
FedExPlanes7.txt
1 medical 111 Boeing767 120000 London
3 packages 555 MD11 180000 Barcelona
4 animals 444 MD11 30000 Miami
6 animals 333 Boeing757 60000 Jackson
7 packages 666 Boeing777 230000 Seattle
9 medical 222 Boeing767 100000 Frankfurt
10 packages 777 Boeing757 90000 Austin
FedExTrucks7.txt
1 688 Memphis
3 820 Denver
4 728 Dallas
Assignment4.java
import java.util.*;
import java.io.*;
public class Assignment4 {
public static void main(String[] args) throws IOException {
//creates plane & truck file objs + cargo terminal
Scanner planeFile = new Scanner(new File("FedExPlanes.txt"));
Scanner truckFile = new Scanner(new File("FedExTrucks.txt"));
CargoTerminal terminal = new CargoTerminal(truckFile.nextInt(),
planeFile.nextInt());
//add semiTrucks into terminal
System.out.println("Loading semi-trucks and planes into cargo
terminal...n");
while(truckFile.hasNext()) {
int dock = truckFile.nextInt();
int number = truckFile.nextInt();
String destination = truckFile.next();
terminal.addSemiTruck(dock, new SemiTruck(number, destination));
}
truckFile.close();
//add planes into terminal
while(planeFile.hasNext()) {
int stand = planeFile.nextInt();
int flight = planeFile.nextInt();
String type = planeFile.next();
double capacity = planeFile.nextDouble();
String destination = planeFile.next();
terminal.addCargoPlane(stand, new CargoPlane(flight, type,
capacity, destination));
}
planeFile.close();
//display planes and trucks
terminal.displayTrucksAndPlanes();
//print tarmac report
System.out.println("Flight tt Stand tt Deparing To tt Type tt
Capacity(lbs)tt n"
+
"----------------------------------------------------------------------------------
----n");
printTarmacStatus(terminal);
}
//status report method for tarmac
public static void printTarmacStatus(CargoTerminal terminal) {
ArrayList reports = new ArrayList();
for(int i = 0; i < terminal.getNumStands(); i++) {
//get plane obj and store vars for report
CargoPlane temp;
if(terminal.getCargoPlane(i) != null) {
temp = terminal.getCargoPlane(i);
int flight = temp.getNumber();
String type = temp.getType();
double capacity = temp.getCapacity();
String destination = temp.getDestination();
reports.add(new PlaneReport(i, flight, type, capacity,
destination));
}
}
Collections.sort(reports);
for(int i = 0; i < reports.size(); i++) {
PlaneReport report = reports.get(i);
System.out.println(report.print());
}
}
}
//define printable interface with abstract method
interface Printable {
public abstract String print();
}
//define cargo terminal class
class CargoTerminal {
private int numberDocks;
private int numberStands;
private SemiTruck[] loadingDock;
private CargoPlane[] tarmac;
//define constructor
public CargoTerminal(int numberDocks, int numberStands) {
this.numberDocks = numberDocks;
this.numberStands = numberStands;
this.loadingDock = new SemiTruck[numberDocks];
this.tarmac = new CargoPlane[numberStands];
}
//define getter methods
public int getNumDocks() {
return this.numberDocks;
}
public int getNumStands() {
return this.numberStands;
}
//add to dock/stand
public void addSemiTruck(int dock, SemiTruck semiTruck) {
this.loadingDock[dock] = semiTruck;
}
public void addCargoPlane(int stand, CargoPlane cargoPlane) {
this.tarmac[stand] = cargoPlane;
}
//truck/plane getters
public SemiTruck getSemiTruck(int dock) {
if(this.loadingDock[dock] != null) {
return this.loadingDock[dock];
}else {
return null;
}
}
public CargoPlane getCargoPlane(int stand) {
if(this.tarmac[stand] != null) {
return this.tarmac[stand];
}else {
return null;
}
}
//print trucks & planes
public void displayTrucksAndPlanes() {
for(int i = 1; i < getNumDocks(); i++) {
System.out.print("Dock # " + i + " t");
}
System.out.print('n');
for(int i = 1; i < getNumDocks(); i++) {
if(this.loadingDock[i] != null) {
System.out.print(this.loadingDock[i].getNumber() + " t
t");
}else {
System.out.print("----- tt");
}
}
System.out.println('n');
for(int i = 1; i < getNumStands(); i++) {
System.out.print("Stand # " + i + " t");
}
System.out.print('n');
for(int i = 1; i < getNumStands(); i++) {
if(this.tarmac[i] != null) {
System.out.print(this.tarmac[i].getNumber() + " tt");
}else {
System.out.print("----- tt");
}
}
System.out.println('n');
}
}
//define semiTruck class
class SemiTruck{
private int truckNumber;
private String destinationCity;
public SemiTruck(int truckNumber, String destinationCity) {
this.truckNumber = truckNumber;
this.destinationCity = destinationCity;
}
public int getNumber() {
return this.truckNumber;
}
public String getDestination() {
return this.destinationCity;
}
}
//define cargoPlane class
class CargoPlane{
private int flightNumber;
private String type;
private double capacity;
private String destinationCity;
//public constructor
public CargoPlane(int flightNumber, String type, double capacity,
String destinationCity) {
this.flightNumber = flightNumber;
this.type = type;
this.capacity = capacity;
this.destinationCity = destinationCity;
}
//define getters
public int getNumber(){
return this.flightNumber;
}
public String getType() {
return this.type;
}
public double getCapacity() {
return this.capacity;
}
public String getDestination() {
return this.destinationCity;
}
}
//define planeReport class & implement printable + comparable.
class PlaneReport implements Printable, Comparable{
private int stand;
private int flightNumber;
private String type;
private double capacity;
private String destinationCity;
//constructor
public PlaneReport(int stand, int flightNumber, String type, double
capacity,
String destinationCity) {
this.stand = stand;
this.flightNumber = flightNumber;
this.type = type;
this.capacity= capacity;
this.destinationCity = destinationCity;
}
//defining abstract methods
@Override
public String print() {
return String.format("%4dtt%2dtt%-15stt%-10st%.2f",
flightNumber, stand, destinationCity, type, capacity);
}
@Override
public int compareTo(PlaneReport otherReport) {
if(capacity > otherReport.capacity) {
return 1;
}
else if (capacity == otherReport.capacity) {
return 0;
}
else {
return -1;
}
}
}
Please Help me on this one. I really appreciate ( Its urgent)! 3. Write a test program (i.e. main) to
do the following: a. Setup steps from assignment 4. These are the same! Use your code or the
solution code on Canvas. i. Create a cargo terminal object ii. Read semi-trucks from
FedExTrucks7.txt (no changes) iii. Create semi-trucks and add to the cargo terminal's loading
dock iv. Read cargo planes from FedExPlanes7.txt (contains one update to cargo planes -
cargoType) v. Create cargo planes and add to the cargo terminal's tarmac vi. Print all semi-trucks
and cargo planes after loading cargo terminal is complete b. Start simulation (new steps for
assignment 7) i. Step 1: Create an air traffic controller object, a taxiways object, and a runaway
object ii. Step 2: Air traffic controller moves all planes in cargo terminal's tarmac to taxiways: -
Move planes from tarmac to taxiways based on taxiway rules (see below) - Print "Moved to
taxiway" message for cargo plane - see output below - Use controller's movePlanesToTaxiways
method. iii. Step 3: After all planes are moved, show that the cargo terminal's tarmac is empty.
iv. Step 4: Air traffic controller moves all planes waiting in taxiways to runway: - Move planes
in taxiways to runway based on runway rules (see below) - Print a "Moved to runway" message
for each plane - see output below - Use controller's movePlanesToRunway method. v. Step 5:
Air traffic controller simulate planes taking off: - After all planes are on the runway, clear each
plane for takeoff - Print a "cleared for takeoff" message for each plane - see output below - Use
controller's clearedForTakeoff method. 4. Test file information: a. Run your code on the updated
file FedExPlanes7.txt. This is a test file, do NOT ASSUME that the order or number of cargo
planes will be the same in the file used for grading. b. File layout is the same except a cargo type
(medical, animals, packages) was added to each plane: Stand # Cargo Type Flight# Type of
Plane Capacity Destination 1 medical 7654 Boeing767 120000 London
Updates to Existing Classes Remove some classes from Assignment 4 , reuse others.
Cargoterminal - Add one new public method: - public CargoPlane removeCargoPlane (int stand)
- Returns and removes the cargo plane stored in the tarmac at the specific stand (slot) - If there is
no cargo plane in stand location (i.e. empty array location), returns null - If there is a cargo plane,
return cargo plane and set location to null. CargoPlane - Must implement Comparable so cargo
planes can be placed into urgent taxiway priority queue. - Add new private data field -
cargoType - string with values medical, animals, and packages - Update constructor - include
cargoType field - Add new public methods isUrgent() - returns true if plane's cargo type is
"medical" or "animals" - isstandard () - returns true if plane's cargo type is "packages" - print() -
displays plane's flight number, destination city, and cargo type public int compareTo(CargoPlane
otherPlane) - Compare planes based on cargo type (medical or animals). - Medical cargo has
highest priority. - See the Tips section for details on comparing planes. New Classes Add three
new classes to cover new entities in the conceptual model: Taxiways, Runway &
AirTrafficController Taxiways - Description - Represents the 2 queues that make up the
taxiways - Private Data Fields - urgentTaxiway - a priority queue of cargo planes whose cargo
type is medical or animal - standardTaxiway - a regular queue of cargo planes whose cargo type
is packages
- Private Data Fields - urgentTaxiway - a priority queue of cargo planes whose cargo type is
medical or animal - standardTaxiway-a regular queue of cargo planes whose cargo type is
packages - Public Methods - Constructor public Taxiways() - Allocate memory for the 2 queues -
Add these new public methods: - isUrgentTaxiwayEmpty - returns true when urgent taxiway
queue is empty - addPlaneToUrgentTaxiway - adds (offers) plane to urgent queue -
removePlaneFromUrgentTaxiway - removes plane from urgent queve - Create the same isEmpty,
add, remove methods for standard taxiway queue Runway - Description - Represents the 1 queue
that makes up the runway - Private Data Fields - runway - a regular queue of cargo planes -
Public Methods - Constructor public Runway() - Allocate memory for the 1 queue - Add these
new public methods: - Create the isEmpty, add, remove methods for runway queue
AirTrafficController - Description - Contains the business logic for moving cargo planes from
tarmac to taxiways then to runway. - Private Date fields - None - Public Methods - Constructor:
none - public void movePlanesToTaxiways (CargoTerminal cargoTerminal, Taxiways taxiways)
- During setup, cargo planes were placed into the cargoTerminal (assignment 4 code). - Move
each plane from tarmac to taxiway based on taxiway rule #1 and #2 (see below)
- When moving a plane to correct taxiway, print a message with taxiway name, flight number,
destination city, and cargo type: Moved to taxiway Urgent flight: 654 London medical Moved to
taxiway Standard flight: 234 Barcelona packages - Rule 1: Planes must be removed from tarmac
in the order of their stands. So, the plane at stand 1 must be removed 11:, then plane at stand 2 ,
etc. - Rule 2: Planes must be moved to the correct taxiway based on cargo type. - If cargo type is
medical or animals - place into urgent taxiway. - If cargo type is packages - place into standard
taxiway. - For the example file, flight 654 to London with medical cargo goes to urgent taxiway,
while flight 234 to Barcelona with packages goes to standard taxiway. - public void
movePlanesToRunway (Taxiways taxiways, Runway runway) - Move planes from taxiways to
runway based on runway rule #1 (see below). - When moving a plane, print message with flight
number, destination city, and cargo type. Moved to runway flight: 654 London medical - Rule 1:
Move planes to the runway based on urgency. - 1rz move planes in urgent taxiway to runway. -
2nd move planes in standard taxiway to runway. - Note: UrgentTaxiway is a priority queue and
ordered by cargo type - Medical cargo has highest priority over animal cargo. - This means
planes carrying medical cargo are placed on the runway first. This is taken care of with the
compareTo method on the cargo plane. - public void clearedForTakeoff (Runway runway) -
Simulate the planes taking off. - Remove cargo planes from runway. - When planes take off,
print message with flight number, destination city, and cargo type: Cleared for takeoff flight: 654
London medical Tips Must Do - Use a priority queue for the urgent taxiway - Use regular queue
for standard taxiway and the runway Tip: Class Name Errors - If you copy your assignment 4
into a new file or use the code on canvas, rename your classes to avoid the error of "Class name
is already defined". For example, I renamed CargoTerminal to CargoTerminal7. Tip: Urgent
Taxiway - For the urgent taxiway (priority queue) to work the CargoPlane class must implement
Comparable - The compareTo method in the cargo plane class must compare the cargo type of
the cargo planes.
- Note: cargo type is a string - With strings, sorted order is normally based on alphabetical order.
- Because "ABD"

Mais conteúdo relacionado

Semelhante a FedExPlanes7.txt1 medical 111 Boeing767 120000 London 3 packages.pdf

import java-util--- import java-io--- class Vertex { -- Constructo.docx
import java-util--- import java-io---   class Vertex {   -- Constructo.docximport java-util--- import java-io---   class Vertex {   -- Constructo.docx
import java-util--- import java-io--- class Vertex { -- Constructo.docx
Blake0FxCampbelld
 
Driverimport java.util.Scanner;A class that keeps a f.pdf
Driverimport java.util.Scanner;A class that keeps a f.pdfDriverimport java.util.Scanner;A class that keeps a f.pdf
Driverimport java.util.Scanner;A class that keeps a f.pdf
arihantstoneart
 
publicclass VehicleParser {publicstatic Vehicle parseStringToVehic.pdf
publicclass VehicleParser {publicstatic Vehicle parseStringToVehic.pdfpublicclass VehicleParser {publicstatic Vehicle parseStringToVehic.pdf
publicclass VehicleParser {publicstatic Vehicle parseStringToVehic.pdf
ANGELMARKETINGJAIPUR
 
Create a system to simulate vehicles at an intersection. Assume th.pdf
Create a system to simulate vehicles at an intersection. Assume th.pdfCreate a system to simulate vehicles at an intersection. Assume th.pdf
Create a system to simulate vehicles at an intersection. Assume th.pdf
archanacomputers1
 
C#i need help creating the instance of stream reader to read from .pdf
C#i need help creating the instance of stream reader to read from .pdfC#i need help creating the instance of stream reader to read from .pdf
C#i need help creating the instance of stream reader to read from .pdf
ajantha11
 
Software Engineer Screening Question - OOP
Software Engineer Screening Question - OOPSoftware Engineer Screening Question - OOP
Software Engineer Screening Question - OOP
jason_scorebig
 
public class Passenger {    public static enum Section {        .pdf
public class Passenger {    public static enum Section {        .pdfpublic class Passenger {    public static enum Section {        .pdf
public class Passenger {    public static enum Section {        .pdf
annesmkt
 
InternetService.java import java.text.DecimalFormat; import jav.pdf
InternetService.java  import java.text.DecimalFormat; import jav.pdfInternetService.java  import java.text.DecimalFormat; import jav.pdf
InternetService.java import java.text.DecimalFormat; import jav.pdf
anjaniar7gallery
 
To write a program that implements the following C++ concepts 1. Dat.pdf
To write a program that implements the following C++ concepts 1. Dat.pdfTo write a program that implements the following C++ concepts 1. Dat.pdf
To write a program that implements the following C++ concepts 1. Dat.pdf
SANDEEPARIHANT
 
Goal The goal of this assignment is to help students understand the.pdf
Goal The goal of this assignment is to help students understand the.pdfGoal The goal of this assignment is to help students understand the.pdf
Goal The goal of this assignment is to help students understand the.pdf
arsmobiles
 
exercises_for_live_coding_Java_advanced-2.pdf
exercises_for_live_coding_Java_advanced-2.pdfexercises_for_live_coding_Java_advanced-2.pdf
exercises_for_live_coding_Java_advanced-2.pdf
enodani2008
 
I have compilation errors that I'm struggling with in my code- please.pdf
I have compilation errors that I'm struggling with in my code- please.pdfI have compilation errors that I'm struggling with in my code- please.pdf
I have compilation errors that I'm struggling with in my code- please.pdf
ColinjHJParsonsa
 

Semelhante a FedExPlanes7.txt1 medical 111 Boeing767 120000 London 3 packages.pdf (20)

import java-util--- import java-io--- class Vertex { -- Constructo.docx
import java-util--- import java-io---   class Vertex {   -- Constructo.docximport java-util--- import java-io---   class Vertex {   -- Constructo.docx
import java-util--- import java-io--- class Vertex { -- Constructo.docx
 
Csci 1101 computer science ii assignment 3/tutorialoutlet
Csci 1101 computer science ii assignment 3/tutorialoutletCsci 1101 computer science ii assignment 3/tutorialoutlet
Csci 1101 computer science ii assignment 3/tutorialoutlet
 
Driverimport java.util.Scanner;A class that keeps a f.pdf
Driverimport java.util.Scanner;A class that keeps a f.pdfDriverimport java.util.Scanner;A class that keeps a f.pdf
Driverimport java.util.Scanner;A class that keeps a f.pdf
 
Chap2 class,objects
Chap2 class,objectsChap2 class,objects
Chap2 class,objects
 
publicclass VehicleParser {publicstatic Vehicle parseStringToVehic.pdf
publicclass VehicleParser {publicstatic Vehicle parseStringToVehic.pdfpublicclass VehicleParser {publicstatic Vehicle parseStringToVehic.pdf
publicclass VehicleParser {publicstatic Vehicle parseStringToVehic.pdf
 
Create a system to simulate vehicles at an intersection. Assume th.pdf
Create a system to simulate vehicles at an intersection. Assume th.pdfCreate a system to simulate vehicles at an intersection. Assume th.pdf
Create a system to simulate vehicles at an intersection. Assume th.pdf
 
C#i need help creating the instance of stream reader to read from .pdf
C#i need help creating the instance of stream reader to read from .pdfC#i need help creating the instance of stream reader to read from .pdf
C#i need help creating the instance of stream reader to read from .pdf
 
Software Engineer Screening Question - OOP
Software Engineer Screening Question - OOPSoftware Engineer Screening Question - OOP
Software Engineer Screening Question - OOP
 
public class Passenger {    public static enum Section {        .pdf
public class Passenger {    public static enum Section {        .pdfpublic class Passenger {    public static enum Section {        .pdf
public class Passenger {    public static enum Section {        .pdf
 
Estendere applicazioni extbase
Estendere applicazioni extbaseEstendere applicazioni extbase
Estendere applicazioni extbase
 
#include iostream #include string#includeiomanip using.docx
#include iostream #include string#includeiomanip using.docx#include iostream #include string#includeiomanip using.docx
#include iostream #include string#includeiomanip using.docx
 
InternetService.java import java.text.DecimalFormat; import jav.pdf
InternetService.java  import java.text.DecimalFormat; import jav.pdfInternetService.java  import java.text.DecimalFormat; import jav.pdf
InternetService.java import java.text.DecimalFormat; import jav.pdf
 
Aircraft Takeoff Simulation with MATLAB
Aircraft Takeoff Simulation with MATLABAircraft Takeoff Simulation with MATLAB
Aircraft Takeoff Simulation with MATLAB
 
To write a program that implements the following C++ concepts 1. Dat.pdf
To write a program that implements the following C++ concepts 1. Dat.pdfTo write a program that implements the following C++ concepts 1. Dat.pdf
To write a program that implements the following C++ concepts 1. Dat.pdf
 
Goal The goal of this assignment is to help students understand the.pdf
Goal The goal of this assignment is to help students understand the.pdfGoal The goal of this assignment is to help students understand the.pdf
Goal The goal of this assignment is to help students understand the.pdf
 
exercises_for_live_coding_Java_advanced-2.pdf
exercises_for_live_coding_Java_advanced-2.pdfexercises_for_live_coding_Java_advanced-2.pdf
exercises_for_live_coding_Java_advanced-2.pdf
 
J2ee standards > CDI
J2ee standards > CDIJ2ee standards > CDI
J2ee standards > CDI
 
I have compilation errors that I'm struggling with in my code- please.pdf
I have compilation errors that I'm struggling with in my code- please.pdfI have compilation errors that I'm struggling with in my code- please.pdf
I have compilation errors that I'm struggling with in my code- please.pdf
 
Flight Landing Distance Study Using SAS
Flight Landing Distance Study Using SASFlight Landing Distance Study Using SAS
Flight Landing Distance Study Using SAS
 
Flight landing Project
Flight landing ProjectFlight landing Project
Flight landing Project
 

Mais de alukkasprince

Mais de alukkasprince (20)

For the generative data model consider in the class t = Xw+ with th.pdf
For the generative data model consider in the class t = Xw+ with th.pdfFor the generative data model consider in the class t = Xw+ with th.pdf
For the generative data model consider in the class t = Xw+ with th.pdf
 
For most of 2022, the Bank of Japan was maintaining yield curve cont.pdf
For most of 2022, the Bank of Japan was maintaining yield curve cont.pdfFor most of 2022, the Bank of Japan was maintaining yield curve cont.pdf
For most of 2022, the Bank of Japan was maintaining yield curve cont.pdf
 
For Happy Harrys company which is a liquor company , develop and de.pdf
For Happy Harrys company which is a liquor company , develop and de.pdfFor Happy Harrys company which is a liquor company , develop and de.pdf
For Happy Harrys company which is a liquor company , develop and de.pdf
 
For tax purposes, in computing the ordinary income of a partnership,.pdf
For tax purposes, in computing the ordinary income of a partnership,.pdfFor tax purposes, in computing the ordinary income of a partnership,.pdf
For tax purposes, in computing the ordinary income of a partnership,.pdf
 
For a population growing in a logistic fashion, the per-capita popul.pdf
For a population growing in a logistic fashion, the per-capita popul.pdfFor a population growing in a logistic fashion, the per-capita popul.pdf
For a population growing in a logistic fashion, the per-capita popul.pdf
 
For a particular large group of people, blood types are distributed .pdf
For a particular large group of people, blood types are distributed .pdfFor a particular large group of people, blood types are distributed .pdf
For a particular large group of people, blood types are distributed .pdf
 
Focus can be on South African Government QUESTION TWO [25] 2.1 Wit.pdf
Focus can be on South African Government QUESTION TWO [25] 2.1 Wit.pdfFocus can be on South African Government QUESTION TWO [25] 2.1 Wit.pdf
Focus can be on South African Government QUESTION TWO [25] 2.1 Wit.pdf
 
Finansal araclar olarak bankalar A. Bor� verecek paras olan i.pdf
Finansal araclar olarak bankalar A. Bor� verecek paras olan i.pdfFinansal araclar olarak bankalar A. Bor� verecek paras olan i.pdf
Finansal araclar olarak bankalar A. Bor� verecek paras olan i.pdf
 
Finansal k�reselleme u sonu�lara yol a�mad a) �demeler dengesinde d.pdf
Finansal k�reselleme u sonu�lara yol a�mad a) �demeler dengesinde d.pdfFinansal k�reselleme u sonu�lara yol a�mad a) �demeler dengesinde d.pdf
Finansal k�reselleme u sonu�lara yol a�mad a) �demeler dengesinde d.pdf
 
find P (D and E)find P (E given D)find P (D or E) 7. [0.411,3 Po.pdf
find P (D and E)find P (E given D)find P (D or E) 7. [0.411,3 Po.pdffind P (D and E)find P (E given D)find P (D or E) 7. [0.411,3 Po.pdf
find P (D and E)find P (E given D)find P (D or E) 7. [0.411,3 Po.pdf
 
Finansal performans �l��tleri, girileri (gelir) ve �klar (maliyetler.pdf
Finansal performans �l��tleri, girileri (gelir) ve �klar (maliyetler.pdfFinansal performans �l��tleri, girileri (gelir) ve �klar (maliyetler.pdf
Finansal performans �l��tleri, girileri (gelir) ve �klar (maliyetler.pdf
 
Find Show Cp and Cpk for normal process that has tolerance, T, cas.pdf
Find  Show Cp and Cpk for normal process that has tolerance, T, cas.pdfFind  Show Cp and Cpk for normal process that has tolerance, T, cas.pdf
Find Show Cp and Cpk for normal process that has tolerance, T, cas.pdf
 
FinanceFVN= PV(1+I)N=$1(1+0.050)3.0=$1.161. What is the futu.pdf
FinanceFVN= PV(1+I)N=$1(1+0.050)3.0=$1.161.  What is the futu.pdfFinanceFVN= PV(1+I)N=$1(1+0.050)3.0=$1.161.  What is the futu.pdf
FinanceFVN= PV(1+I)N=$1(1+0.050)3.0=$1.161. What is the futu.pdf
 
Explain the pathophysiology of Hypothyroidism What is the pathophysi.pdf
Explain the pathophysiology of Hypothyroidism What is the pathophysi.pdfExplain the pathophysiology of Hypothyroidism What is the pathophysi.pdf
Explain the pathophysiology of Hypothyroidism What is the pathophysi.pdf
 
Filimonov Inc. has the following information related to purchases an.pdf
Filimonov Inc. has the following information related to purchases an.pdfFilimonov Inc. has the following information related to purchases an.pdf
Filimonov Inc. has the following information related to purchases an.pdf
 
FIFO y�ntemi kullanlarak, en erken envanter almlarnn _______ kapsand.pdf
FIFO y�ntemi kullanlarak, en erken envanter almlarnn _______ kapsand.pdfFIFO y�ntemi kullanlarak, en erken envanter almlarnn _______ kapsand.pdf
FIFO y�ntemi kullanlarak, en erken envanter almlarnn _______ kapsand.pdf
 
Ferrante Company sells 40,000 units at $44 per unit. Variable costs .pdf
Ferrante Company sells 40,000 units at $44 per unit. Variable costs .pdfFerrante Company sells 40,000 units at $44 per unit. Variable costs .pdf
Ferrante Company sells 40,000 units at $44 per unit. Variable costs .pdf
 
Farrah, harici bir aratrma irketi tarafndan toplanan m�teri memnuniy.pdf
Farrah, harici bir aratrma irketi tarafndan toplanan m�teri memnuniy.pdfFarrah, harici bir aratrma irketi tarafndan toplanan m�teri memnuniy.pdf
Farrah, harici bir aratrma irketi tarafndan toplanan m�teri memnuniy.pdf
 
Factors that Shift the IS Curve Which of the following will shift th.pdf
Factors that Shift the IS Curve Which of the following will shift th.pdfFactors that Shift the IS Curve Which of the following will shift th.pdf
Factors that Shift the IS Curve Which of the following will shift th.pdf
 
Explain two (2) examples of evidence-based nursing care that could b.pdf
Explain two (2) examples of evidence-based nursing care that could b.pdfExplain two (2) examples of evidence-based nursing care that could b.pdf
Explain two (2) examples of evidence-based nursing care that could b.pdf
 

Último

Beyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactBeyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global Impact
PECB
 
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in DelhiRussian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
kauryashika82
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Krashi Coaching
 
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
fonyou31
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptx
heathfieldcps1
 

Último (20)

Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdf
 
Beyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactBeyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global Impact
 
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in DelhiRussian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
 
Arihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfArihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdf
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)
 
Mattingly "AI & Prompt Design: The Basics of Prompt Design"
Mattingly "AI & Prompt Design: The Basics of Prompt Design"Mattingly "AI & Prompt Design: The Basics of Prompt Design"
Mattingly "AI & Prompt Design: The Basics of Prompt Design"
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and Mode
 
Web & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfWeb & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdf
 
Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104
 
Z Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphZ Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot Graph
 
9548086042 for call girls in Indira Nagar with room service
9548086042  for call girls in Indira Nagar  with room service9548086042  for call girls in Indira Nagar  with room service
9548086042 for call girls in Indira Nagar with room service
 
Unit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxUnit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptx
 
APM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAPM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across Sectors
 
Student login on Anyboli platform.helpin
Student login on Anyboli platform.helpinStudent login on Anyboli platform.helpin
Student login on Anyboli platform.helpin
 
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
 
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
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introduction
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptx
 
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptxINDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
 

FedExPlanes7.txt1 medical 111 Boeing767 120000 London 3 packages.pdf

  • 1. FedExPlanes7.txt 1 medical 111 Boeing767 120000 London 3 packages 555 MD11 180000 Barcelona 4 animals 444 MD11 30000 Miami 6 animals 333 Boeing757 60000 Jackson 7 packages 666 Boeing777 230000 Seattle 9 medical 222 Boeing767 100000 Frankfurt 10 packages 777 Boeing757 90000 Austin FedExTrucks7.txt 1 688 Memphis 3 820 Denver 4 728 Dallas Assignment4.java import java.util.*; import java.io.*; public class Assignment4 { public static void main(String[] args) throws IOException { //creates plane & truck file objs + cargo terminal Scanner planeFile = new Scanner(new File("FedExPlanes.txt")); Scanner truckFile = new Scanner(new File("FedExTrucks.txt")); CargoTerminal terminal = new CargoTerminal(truckFile.nextInt(), planeFile.nextInt()); //add semiTrucks into terminal System.out.println("Loading semi-trucks and planes into cargo terminal...n"); while(truckFile.hasNext()) { int dock = truckFile.nextInt(); int number = truckFile.nextInt(); String destination = truckFile.next(); terminal.addSemiTruck(dock, new SemiTruck(number, destination)); } truckFile.close(); //add planes into terminal while(planeFile.hasNext()) { int stand = planeFile.nextInt();
  • 2. int flight = planeFile.nextInt(); String type = planeFile.next(); double capacity = planeFile.nextDouble(); String destination = planeFile.next(); terminal.addCargoPlane(stand, new CargoPlane(flight, type, capacity, destination)); } planeFile.close(); //display planes and trucks terminal.displayTrucksAndPlanes(); //print tarmac report System.out.println("Flight tt Stand tt Deparing To tt Type tt Capacity(lbs)tt n" + "---------------------------------------------------------------------------------- ----n"); printTarmacStatus(terminal); } //status report method for tarmac public static void printTarmacStatus(CargoTerminal terminal) { ArrayList reports = new ArrayList(); for(int i = 0; i < terminal.getNumStands(); i++) { //get plane obj and store vars for report CargoPlane temp; if(terminal.getCargoPlane(i) != null) { temp = terminal.getCargoPlane(i); int flight = temp.getNumber(); String type = temp.getType(); double capacity = temp.getCapacity(); String destination = temp.getDestination(); reports.add(new PlaneReport(i, flight, type, capacity, destination)); } } Collections.sort(reports);
  • 3. for(int i = 0; i < reports.size(); i++) { PlaneReport report = reports.get(i); System.out.println(report.print()); } } } //define printable interface with abstract method interface Printable { public abstract String print(); } //define cargo terminal class class CargoTerminal { private int numberDocks; private int numberStands; private SemiTruck[] loadingDock; private CargoPlane[] tarmac; //define constructor public CargoTerminal(int numberDocks, int numberStands) { this.numberDocks = numberDocks; this.numberStands = numberStands; this.loadingDock = new SemiTruck[numberDocks]; this.tarmac = new CargoPlane[numberStands]; } //define getter methods public int getNumDocks() { return this.numberDocks; } public int getNumStands() { return this.numberStands; } //add to dock/stand public void addSemiTruck(int dock, SemiTruck semiTruck) { this.loadingDock[dock] = semiTruck; } public void addCargoPlane(int stand, CargoPlane cargoPlane) { this.tarmac[stand] = cargoPlane;
  • 4. } //truck/plane getters public SemiTruck getSemiTruck(int dock) { if(this.loadingDock[dock] != null) { return this.loadingDock[dock]; }else { return null; } } public CargoPlane getCargoPlane(int stand) { if(this.tarmac[stand] != null) { return this.tarmac[stand]; }else { return null; } } //print trucks & planes public void displayTrucksAndPlanes() { for(int i = 1; i < getNumDocks(); i++) { System.out.print("Dock # " + i + " t"); } System.out.print('n'); for(int i = 1; i < getNumDocks(); i++) { if(this.loadingDock[i] != null) { System.out.print(this.loadingDock[i].getNumber() + " t t"); }else { System.out.print("----- tt"); } } System.out.println('n'); for(int i = 1; i < getNumStands(); i++) { System.out.print("Stand # " + i + " t"); } System.out.print('n');
  • 5. for(int i = 1; i < getNumStands(); i++) { if(this.tarmac[i] != null) { System.out.print(this.tarmac[i].getNumber() + " tt"); }else { System.out.print("----- tt"); } } System.out.println('n'); } } //define semiTruck class class SemiTruck{ private int truckNumber; private String destinationCity; public SemiTruck(int truckNumber, String destinationCity) { this.truckNumber = truckNumber; this.destinationCity = destinationCity; } public int getNumber() { return this.truckNumber; } public String getDestination() { return this.destinationCity; } } //define cargoPlane class class CargoPlane{ private int flightNumber; private String type; private double capacity; private String destinationCity; //public constructor public CargoPlane(int flightNumber, String type, double capacity, String destinationCity) { this.flightNumber = flightNumber;
  • 6. this.type = type; this.capacity = capacity; this.destinationCity = destinationCity; } //define getters public int getNumber(){ return this.flightNumber; } public String getType() { return this.type; } public double getCapacity() { return this.capacity; } public String getDestination() { return this.destinationCity; } } //define planeReport class & implement printable + comparable. class PlaneReport implements Printable, Comparable{ private int stand; private int flightNumber; private String type; private double capacity; private String destinationCity; //constructor public PlaneReport(int stand, int flightNumber, String type, double capacity, String destinationCity) { this.stand = stand; this.flightNumber = flightNumber; this.type = type; this.capacity= capacity; this.destinationCity = destinationCity; } //defining abstract methods
  • 7. @Override public String print() { return String.format("%4dtt%2dtt%-15stt%-10st%.2f", flightNumber, stand, destinationCity, type, capacity); } @Override public int compareTo(PlaneReport otherReport) { if(capacity > otherReport.capacity) { return 1; } else if (capacity == otherReport.capacity) { return 0; } else { return -1; } } } Please Help me on this one. I really appreciate ( Its urgent)! 3. Write a test program (i.e. main) to do the following: a. Setup steps from assignment 4. These are the same! Use your code or the solution code on Canvas. i. Create a cargo terminal object ii. Read semi-trucks from FedExTrucks7.txt (no changes) iii. Create semi-trucks and add to the cargo terminal's loading dock iv. Read cargo planes from FedExPlanes7.txt (contains one update to cargo planes - cargoType) v. Create cargo planes and add to the cargo terminal's tarmac vi. Print all semi-trucks and cargo planes after loading cargo terminal is complete b. Start simulation (new steps for assignment 7) i. Step 1: Create an air traffic controller object, a taxiways object, and a runaway object ii. Step 2: Air traffic controller moves all planes in cargo terminal's tarmac to taxiways: - Move planes from tarmac to taxiways based on taxiway rules (see below) - Print "Moved to taxiway" message for cargo plane - see output below - Use controller's movePlanesToTaxiways method. iii. Step 3: After all planes are moved, show that the cargo terminal's tarmac is empty. iv. Step 4: Air traffic controller moves all planes waiting in taxiways to runway: - Move planes in taxiways to runway based on runway rules (see below) - Print a "Moved to runway" message for each plane - see output below - Use controller's movePlanesToRunway method. v. Step 5: Air traffic controller simulate planes taking off: - After all planes are on the runway, clear each plane for takeoff - Print a "cleared for takeoff" message for each plane - see output below - Use
  • 8. controller's clearedForTakeoff method. 4. Test file information: a. Run your code on the updated file FedExPlanes7.txt. This is a test file, do NOT ASSUME that the order or number of cargo planes will be the same in the file used for grading. b. File layout is the same except a cargo type (medical, animals, packages) was added to each plane: Stand # Cargo Type Flight# Type of Plane Capacity Destination 1 medical 7654 Boeing767 120000 London Updates to Existing Classes Remove some classes from Assignment 4 , reuse others. Cargoterminal - Add one new public method: - public CargoPlane removeCargoPlane (int stand) - Returns and removes the cargo plane stored in the tarmac at the specific stand (slot) - If there is no cargo plane in stand location (i.e. empty array location), returns null - If there is a cargo plane, return cargo plane and set location to null. CargoPlane - Must implement Comparable so cargo planes can be placed into urgent taxiway priority queue. - Add new private data field - cargoType - string with values medical, animals, and packages - Update constructor - include cargoType field - Add new public methods isUrgent() - returns true if plane's cargo type is "medical" or "animals" - isstandard () - returns true if plane's cargo type is "packages" - print() - displays plane's flight number, destination city, and cargo type public int compareTo(CargoPlane otherPlane) - Compare planes based on cargo type (medical or animals). - Medical cargo has highest priority. - See the Tips section for details on comparing planes. New Classes Add three new classes to cover new entities in the conceptual model: Taxiways, Runway & AirTrafficController Taxiways - Description - Represents the 2 queues that make up the taxiways - Private Data Fields - urgentTaxiway - a priority queue of cargo planes whose cargo type is medical or animal - standardTaxiway - a regular queue of cargo planes whose cargo type is packages - Private Data Fields - urgentTaxiway - a priority queue of cargo planes whose cargo type is medical or animal - standardTaxiway-a regular queue of cargo planes whose cargo type is packages - Public Methods - Constructor public Taxiways() - Allocate memory for the 2 queues - Add these new public methods: - isUrgentTaxiwayEmpty - returns true when urgent taxiway queue is empty - addPlaneToUrgentTaxiway - adds (offers) plane to urgent queue - removePlaneFromUrgentTaxiway - removes plane from urgent queve - Create the same isEmpty, add, remove methods for standard taxiway queue Runway - Description - Represents the 1 queue that makes up the runway - Private Data Fields - runway - a regular queue of cargo planes - Public Methods - Constructor public Runway() - Allocate memory for the 1 queue - Add these new public methods: - Create the isEmpty, add, remove methods for runway queue AirTrafficController - Description - Contains the business logic for moving cargo planes from tarmac to taxiways then to runway. - Private Date fields - None - Public Methods - Constructor:
  • 9. none - public void movePlanesToTaxiways (CargoTerminal cargoTerminal, Taxiways taxiways) - During setup, cargo planes were placed into the cargoTerminal (assignment 4 code). - Move each plane from tarmac to taxiway based on taxiway rule #1 and #2 (see below) - When moving a plane to correct taxiway, print a message with taxiway name, flight number, destination city, and cargo type: Moved to taxiway Urgent flight: 654 London medical Moved to taxiway Standard flight: 234 Barcelona packages - Rule 1: Planes must be removed from tarmac in the order of their stands. So, the plane at stand 1 must be removed 11:, then plane at stand 2 , etc. - Rule 2: Planes must be moved to the correct taxiway based on cargo type. - If cargo type is medical or animals - place into urgent taxiway. - If cargo type is packages - place into standard taxiway. - For the example file, flight 654 to London with medical cargo goes to urgent taxiway, while flight 234 to Barcelona with packages goes to standard taxiway. - public void movePlanesToRunway (Taxiways taxiways, Runway runway) - Move planes from taxiways to runway based on runway rule #1 (see below). - When moving a plane, print message with flight number, destination city, and cargo type. Moved to runway flight: 654 London medical - Rule 1: Move planes to the runway based on urgency. - 1rz move planes in urgent taxiway to runway. - 2nd move planes in standard taxiway to runway. - Note: UrgentTaxiway is a priority queue and ordered by cargo type - Medical cargo has highest priority over animal cargo. - This means planes carrying medical cargo are placed on the runway first. This is taken care of with the compareTo method on the cargo plane. - public void clearedForTakeoff (Runway runway) - Simulate the planes taking off. - Remove cargo planes from runway. - When planes take off, print message with flight number, destination city, and cargo type: Cleared for takeoff flight: 654 London medical Tips Must Do - Use a priority queue for the urgent taxiway - Use regular queue for standard taxiway and the runway Tip: Class Name Errors - If you copy your assignment 4 into a new file or use the code on canvas, rename your classes to avoid the error of "Class name is already defined". For example, I renamed CargoTerminal to CargoTerminal7. Tip: Urgent Taxiway - For the urgent taxiway (priority queue) to work the CargoPlane class must implement Comparable - The compareTo method in the cargo plane class must compare the cargo type of the cargo planes. - Note: cargo type is a string - With strings, sorted order is normally based on alphabetical order. - Because "ABD"