APCSA/U5/L6/runner_Plane.java
2026-03-25 09:44:12 -07:00

30 lines
1.1 KiB
Java

import java.util.Scanner;
public class runner_Plane {
public static void main(String str[]) {
Scanner scan = new Scanner(System.in);
Plane p = new Plane();
String instruction = "";
while (!instruction.equals("q")) {
System.out.println(p);
System.out.println("Location: " + p.getLocation());
System.out.println(
"Type \"u\" to move upwards, \"d\" to move downwards, \"n\" for new Plane, \"q\" to quit."
);
instruction = scan.nextLine();
if (instruction.equals("u")) {
p.upward();
} else if (instruction.equals("d")) {
p.downward();
} else if (instruction.equals("n")) {
System.out.println("Starting location for a new Plane?");
int start = scan.nextInt();
p = new Plane(start);
scan.nextLine();
} else if (!instruction.equals("q")) {
System.out.println("Instruction not recognized.");
}
}
}
}