Professional Documents
Culture Documents
Name: Muhammad Hamza Aziz
Name: Muhammad Hamza Aziz
Name: Muhammad Hamza Aziz
Assignment 3
}
}
}
}
class Flight {
public String flightid;
public int fuel;
public int passengers;
public Flight(String flightid,int fuel,int passengers) {
this.fuel=fuel;
this.flightid=flightid;
this.passengers=passengers;
}
public void setFlightID(String flightid) {
this.flightid=flightid;
}
public void setpassengers(int passengers) {
this.passengers=passengers;
}
public int getpassengers() {
return passengers;
}
public String getFlightid() {
return flightid;
}
public void setFuel(int fuel) {
this.fuel=fuel;
}
public int getFuel() {
return fuel;
}
}
class ArrivingFlight{
private final int SIZE= 10;
private Flight [] LQ=new Flight[SIZE];
private Flight [] LQ1=new Flight[SIZE];
private Flight [] newArry=new Flight[SIZE];
private int LQcounter;
private int LQcounter1;
int newArryCounter;
private int temp;
private int a;
public ArrivingFlight() {
LQcounter=0;
newArryCounter=0;
LQcounter1=0;
temp=0;
a=0;
}
public boolean Enqueue(Flight f)
{
if(LQcounter>LQcounter1) {
LQ1[LQcounter1++]=f;
return true;
}
if(LQcounter==LQcounter1) {
LQ[LQcounter++]=f;
return true;
}
if(LQcounter<LQcounter1) {
LQ[LQcounter++]=f;
return true;
}
return false;
}
public boolean Dequeue() {
int front=0;
Flight objectt;
Flight object2;
objectt=LQ[front];
object2=LQ1[front];
for(int i=0;i<LQcounter;i++) {
LQ[i]=LQ[i+1];
}
for(int i=0;i<LQcounter1;i++) {
LQ1[i]=LQ1[i+1];
}
LQcounter--;
LQcounter1--;
return true;
}
public boolean isFull()
{
if(LQcounter>=SIZE&&LQcounter1>=SIZE) {
return true;
}
return false;
}
public boolean isEmpty() {
if(LQcounter<=0&&LQcounter1<=0) {
return true;
}
return false;
}
public boolean Emergency(String id) {
int top=0;
int a=0;
String flightID=id;
Flight stack[]=new Flight[SIZE];
Flight emObj;
if(LQcheck(flightID)) {
a=LQcounter-1;
while(!LQ[a].getFlightid().equals(id)) {
stack[top++]=LQ[a--];
}
newArry[newArryCounter++]=LQ[a];
while(top>=0) {
LQ[a++]=stack[top--];
}
LQcounter--;
return true;
}
if(LQcheck1(id)) {
int b=LQcounter1-1;
while(!LQ1[b].getFlightid().equals(id)) {
stack[top++]=LQ1[b--];
}
newArry[newArryCounter++]=LQ1[b];
while(top>=0) {
LQ1[b++]=stack[top--];
}
LQcounter1--;
return true;
}
return false;
}
public boolean LQcheck(String id)
{
}
class DepartingFlight{
private final int SIZE= 10;
private Flight [] TO1=new Flight[SIZE];
private Flight [] TO2=new Flight[SIZE];
public int temp;
private int a;