Air Traffic

Air traffic control

Page 1 of 1

3 Replies - 2038 Views - Last Post: 28 March 2010 - 08:15 PM Rate Topic: -----

#1 Simohammed  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 6
  • Joined: 09-March 10

Air Traffic

Posted 26 March 2010 - 08:11 PM

Hi all,
I tried to create a program that shows how the traffic control works in the airport, there will class for flights, times, availaibility, current altittude, directions, deparure, estimated timing, origin, distination. I provided get and set methods to manipulate this and other attributes.
Here are two files I came up with.
I need your help to make that shorter.
Thanks a bunch
import java.util.Scanner;

public class Flightstest{

private enum Status{WAITING, TAKINGOFF, CLIMBING, FLYING, WAITINGDESCENT, DESCENDING, LANDING};
public static void main(String[] args){

	int flightpick=0;
	Status flightstatus;
	Scanner input= new Scanner(System.in);
	Flights flight1= new Flights("BMW","California","DC", 28, 0, 14, 30, 25, 2, 30, 50);
	Flights flight2= new Flights("Honda","DC","California", 28, 12000, 9, 30, 25, 2, 30, 50);
	Flights flight3= new Flights("Ferrari","DC","France", 28, 5000, 8, 50, 25, 6, 30, 50);


	System.out.println("Type 1, 2 or 3 to view flight ");
	flightpick=input.nextInt();

	while(flightpick != 999){

	switch(flightpick){


		case 1:
		flightstatus=Status.TAKINGOFF;
		System.out.println("Flight 1 is currently Taking Off.");
		System.out.println();
		flight1.planeinfo();
		System.out.println();
		flight1.changealtitude(5000);
		System.out.println();

		System.out.println("Flight 1 is now FLYING.");
						
System.out.println();

						System.out.println("Type 1, 2 or 3 to view flight ");
						flightpick=input.nextInt();

						break;

						case 2:

						flightstatus=Status.FLYING;
						System.out.println("Flight 2 is currently flying.");
						System.out.println();

						flight2.planeinfo();

						System.out.println("Type 4 to descent the plane.");
						System.out.println("Type 1, 2 or 3 to view flight ");
						flightpick=input.nextInt();
						System.out.println();

						if (flightpick==4){

							flightstatus=Status.DESCENDING;
							flight2.descending();
							System.out.println();

							System.out.println("Type 4 to land the plane.");
							System.out.println("Type 1, 2 or 3 to view flight");
							flightpick=input.nextInt();
							System.out.println();

							if(flightpick==4){

								flightstatus=Status.LANDING;
								flight2.landing();
								System.out.println();
								System.out.println("Type 1, 2 or 3 to view flight ");
								flightpick=input.nextInt();
							}

							else

							break;
						}

						case 3:

						flightstatus=Status.WAITINGDESCENT;
						System.out.println("Flight 3 is waiting for descent.");
						System.out.println();
						flight3.planeinfo();
						System.out.println();
						System.out.println("Type 4 when plane is clear for landing.");
						System.out.println("Type 1, 2 or 3 to view flight ");
						flightpick=input.nextInt();
						System.out.println();

						if(flightpick==4){

							flight3.descending();

						}

						break;





	}
	}
	}
	}

The 2 nd file

import java.util.Scanner;

public class Flightstest{


	private enum Status{WAITING, TAKINGOFF, CLIMBING, FLYING, WAITINGDESCENT, DESCENDING, LANDING};
	public static void main(String[] args){

		int flightpick=0;
		Status flightstatus;
		Scanner input= new Scanner(System.in);
		Flights flight1= new Flights("BMW","California","DC", 28, 0, 14, 30, 25, 2, 30, 50);
		Flights flight2= new Flights("Honda","DC","California", 28, 12000, 9, 30, 25, 2, 30, 50);
		Flights flight3= new Flights("Ferrari","DC","France", 28, 5000, 8, 50, 25, 6, 30, 50);


		System.out.println("Type 1, 2 or 3 to view flight ");
		flightpick=input.nextInt();

		while(flightpick != 999){

			switch(flightpick){


						case 1:
						flightstatus=Status.TAKINGOFF;
						System.out.println("Flight 1 is currently Taking Off.");
						System.out.println();

						flight1.planeinfo();
						System.out.println();
						flight1.changealtitude(5000);
						System.out.println();

						System.out.println("Flight 1 is now FLYING.");
						System.out.println();

						System.out.println("Type 1, 2 or 3 to view flight ");
						flightpick=input.nextInt();

						break;

						case 2:

						flightstatus=Status.FLYING;
						System.out.println("Flight 2 is currently flying.");
						System.out.println();

						flight2.planeinfo();

						System.out.println("Type 4 to descent the plane.");
						System.out.println("Type 1, 2 or 3 to view flight ");
						flightpick=input.nextInt();
						System.out.println();

						if (flightpick==4){

							flightstatus=Status.DESCENDING;
							flight2.descending();
							System.out.println();

							System.out.println("Type 4 to land the plane.");
							System.out.println("Type 1, 2 or 3 to view flight");
							flightpick=input.nextInt();
							System.out.println();

							if(flightpick==4){

								flightstatus=Status.LANDING;
								flight2.landing();
								System.out.println();
								System.out.println("Type 1, 2 or 3 to view flight ");
								flightpick=input.nextInt();
							}

							else

							break;
						}

						case 3:

						flightstatus=Status.WAITINGDESCENT;
						System.out.println("Flight 3 is waiting for descent.");
						System.out.println();
						flight3.planeinfo();
						System.out.println();
						System.out.println("Type 4 when plane is clear for landing.");
						System.out.println("Type 1, 2 or 3 to view flight ");
						flightpick=input.nextInt();
						System.out.println();

						if(flightpick==4){

							flight3.descending();

						}

						break;





	}
	}
	}
	}

This post has been edited by JackOfAllTrades: 28 March 2010 - 05:47 PM
Reason for edit:: Added code tags. Please [code]...PUT YOUR CODE IN HERE...[/code]


Is This A Good Question/Topic? 0
  • +

Replies To: Air Traffic

#2 xor-logic  Icon User is offline

  • HAL9000 was an Apple product
  • member icon

Reputation: 128
  • View blog
  • Posts: 764
  • Joined: 04-February 10

Re: Air Traffic

Posted 26 March 2010 - 11:57 PM

:code:
Was This Post Helpful? 0
  • +
  • -

#3 Simohammed  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 6
  • Joined: 09-March 10

Re: Air Traffic

Posted 28 March 2010 - 05:45 PM

which button man?
Any help then!!
Was This Post Helpful? 0
  • +
  • -

#4 pbl  Icon User is offline

  • There is nothing you can't do with a JTable
  • member icon

Reputation: 8328
  • View blog
  • Posts: 31,857
  • Joined: 06-March 08

Re: Air Traffic

Posted 28 March 2010 - 08:15 PM

View PostSimohammed, on 26 March 2010 - 09:11 PM, said:

Hi all,
I tried to create a program that shows how the traffic control works in the airport, there will class for flights, times, availaibility, current altittude, directions, deparure, estimated timing, origin, distination. I provided get and set methods to manipulate this and other attributes.
Here are two files I came up with.

Will not all of these characteristics be proper to a single class Fkight ? iunstead of having a class for each of them ???
Better to review your architecture or code in Prolog who does not have basic data type
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1