Untitled
unknown
plain_text
4 years ago
2.0 kB
5
Indexable
/* Assignment 2 - Control Tower */
/* Class name - must be "Assignment2" in order to run */
import java.util.Scanner;
import assignment2.Airplane;
public class Assignment2
{
public static void main(String[] args)
{
Scanner scan = new Scanner(System.in);
//Interrogate the traitor
System.out.println("Enter the details of the second airplane (call-sign, distance, bearing and altitude):");
String s1 = scan.nextLine();
double s2 = scan.nextDouble();
int s3 = scan.nextInt();
int s4 = scan.nextInt();
//Set up planes
Airplane plane = new Airplane();
Airplane plane2 = new Airplane(s1, s2, s3, s4);
//Calculate distance from plane1
double dist = plane.distTo(plane2);
int planeAlt1 = plane.getAlt();
int planeAbsAlt = (int) Math.abs(planeAlt1 - s4);
System.out.println("\nInitial Positions:");
System.out.println("\"Airplane 1\": " + plane.toString());
System.out.println("\"Airplane 2\": " + plane2.toString());
System.out.println("The distance between the planes is " + dist + " miles.");
System.out.println("The difference in height between the planes is " + planeAbsAlt + " feet.");
//Gain altitude 4 times to 4000 feet, lose 1000 feet on plane2
plane.gainAlt();
plane.gainAlt();
plane.gainAlt();
plane.gainAlt();
plane2.loseAlt();
plane2.loseAlt();
plane.move(10.5,50);
plane2.move(8.0,125);
//Second plane calculator
double dist2 = plane.distTo(plane2);
int planeAlt2 = plane.getAlt();
int planealt22 = plane2.getAlt();
int planeAbsAlt2 = (int) Math.abs(planeAlt2 - planealt22);
//Voila~
System.out.println("\nNew Positions:");
System.out.println("\"Airplane 1\": " + plane.toString());
System.out.println("\"Airplane 2\": " + plane2.toString());
System.out.println("The distance between the planes is " + dist2 + " miles.");
System.out.println("The difference in height between the planes is " + planeAbsAlt2 + " feet.");
}
}
Editor is loading...