Skip to content

Instantly share code, notes, and snippets.

@gitaficionado
Created November 6, 2020 14:01
Show Gist options
  • Save gitaficionado/31564adf3b1ad5db042364d6151bc710 to your computer and use it in GitHub Desktop.
Save gitaficionado/31564adf3b1ad5db042364d6151bc710 to your computer and use it in GitHub Desktop.
The Control Tower assignment requires students to write a short program in Java to determine the positions of airplanes relative after changes have been made to their initial starting positions.
/* Assignment 2 - Control Tower */
/* Class name - must be "Assignment2" in order to run*/
import java.util.Scanner;
//import edhesive.assignment2.Airplane;
public class Assignment2
{
public static void main(String[] args)
{
// Create Scanner and Airplane 1
______________ scan = __________ Scanner(System.in); // Create Scanner object here.
Airplane ___ = new _______________(); //create new object of type Airplane called p1
// Get Airplane 2 details
System.out.println("Enter the details of the second airplane (call-sign, distance, bearing and altitude):");
String ____g__ = _____.______(); // create string called "cs" for call sign for code sign
double dist = scan.nextDouble(); ed
____ dir = scan.nextInt(); // Creaete input from user to hold direction.
______ _____ = _____.nextInt(); //Creaete input from user to altitude
cs = ______.________(); // Use String method to conert call sign to Upper Calse Letters
/* To create a plane with the characteristics described above, call
* the constructor with the variables matching the signature:
* (String cs, double dist, int dir, int alt).
*/
_______ _________ = _______ ________(____, ____, ____ , ____ ); // Create new object that takes in call sign
// distance, direction, and alt
/* When the airplane objects p1 and p2 are concatenated into a
* String, the toString method is called automatically, causing the
* representation requested by the assignment to be printed. When
* the method call p1.distTo(p2) is concatenated into the String,
* the result of this call is concatenated into the string.
*/
System.out.println("\nInitial Positions:");
System.out.println("\"Airplane 1\": " + ___);
System.out.println("\"Airplane 2\": " + ___);
System.out.println("The distance between the planes is " + ___.______(p2) + " _____.");
System.out.println("The difference in height between the planes is " + ______ .____ (___ __() - ___ _____()) + " feet.");
// Calling the gainAlt method 4 times moves the plane up 4000 feet
p1.____________();
p1.___________();
p1.___________();
p1.__________();
//Calling the loseAlt method 2 times moves the plane down 2000 feet
___.________();
___.___________();
// Moves the planes the desired distances and directions
___.____________(10.5, 50);
__.move(8.0, 125);
//Repeat print statements from before
System.out.println("\nNew Positions:");
System.out.println("\"Airplane 1\": " + __);
System.out.println("\"Airplane 2\": " + ___);
System.out.println("The distance between the planes is " + ___.________(p2) + " miles.");
System.out.println("The difference in height between the planes is " + ________________)-___.________()) + " feet.");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment