From e93ec34e1d904612766b771286ffce30ac20c0c1 Mon Sep 17 00:00:00 2001 From: "corinna.sailer" Date: Mon, 29 Jun 2020 15:38:08 +0200 Subject: [PATCH] Koordinaten Eingabe MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Zahl eingeben um Start/endpunkt auszuwählen --- src/app/_0_Constants.java | 8 +-- src/app/_1_GeoAnimation_CreateAnimation.java | 67 +++++++++++++++++++- 2 files changed, 69 insertions(+), 6 deletions(-) diff --git a/src/app/_0_Constants.java b/src/app/_0_Constants.java index fd60ce5..b482be8 100644 --- a/src/app/_0_Constants.java +++ b/src/app/_0_Constants.java @@ -40,9 +40,9 @@ public class _0_Constants { public static double VELOCITY = 10; // Die Geschwindigkeit sollte Pi betragen // Winkel vom Startpunkt & Endpunkt - public static double PHI_S = 139.72; - public static double THETA_S = 35.68; - public static double PHI_E = 52.52; - public static double THETA_E = 13.37; + public static double PHI_S; + public static double THETA_S; + public static double PHI_E; + public static double THETA_E; } diff --git a/src/app/_1_GeoAnimation_CreateAnimation.java b/src/app/_1_GeoAnimation_CreateAnimation.java index 4d14075..5f3fd6a 100644 --- a/src/app/_1_GeoAnimation_CreateAnimation.java +++ b/src/app/_1_GeoAnimation_CreateAnimation.java @@ -1,5 +1,5 @@ package app; - +import java.util.Scanner; import java.util.Timer; //import javax.swing.JButton; @@ -14,7 +14,8 @@ public class _1_GeoAnimation_CreateAnimation { private static JFrame frame; public static void main(String[] args) { - + startmenu(); + endmenu(); //open new thread for time measurement ApplicationTime animThread = new ApplicationTime(); animThread.start(); @@ -25,6 +26,68 @@ public class _1_GeoAnimation_CreateAnimation { timer.scheduleAtFixedRate(new FrameUpdate(frame), 100, _0_Constants.TPF); } + public static void startmenu() { + int select; + Scanner scan = new Scanner(System.in); + System.out.println("Start:"); + System.out.println("1: Berlin"); + System.out.println("2: Tokyo"); + System.out.println("3: New York"); + System.out.println("4: Kapstadt"); + select = scan.nextInt(); + switch(select) { + case 1: + _0_Constants.PHI_S = 52.52; //breite + _0_Constants.THETA_S = 13.37; //Länge + break; + case 2: + _0_Constants.PHI_S = 139.72; + _0_Constants.THETA_S = 35.68; + break; + case 3: + _0_Constants.PHI_S = -74.0; + _0_Constants.THETA_S = 40.71; + System.out.println("NY"); + break; + case 4: + _0_Constants.PHI_S = 18.42; + _0_Constants.THETA_S = -33.9; + break; + } + } + + public static void endmenu() { + int select; + Scanner scanner = new Scanner(System.in); + System.out.println("Das Ziel:"); + System.out.println("1: Berlin"); + System.out.println("2: Tokyo"); + System.out.println("3: New York"); + System.out.println("4: Kapstadt"); + select = scanner.nextInt(); + switch(select) { + case 1: + _0_Constants.PHI_E = 52.52; //breite + _0_Constants.THETA_E = 13.37; //Länge + break; + case 2: + _0_Constants.PHI_E = 139.72; + _0_Constants.THETA_E = 35.68; + break; + case 3: + _0_Constants.PHI_E = -74; + _0_Constants.THETA_E = 40.71; + break; + case 4: + _0_Constants.PHI_E = 18.42; + _0_Constants.THETA_E = -33.9; + break; + } + if(_0_Constants.PHI_E == _0_Constants.PHI_S && _0_Constants.THETA_E == _0_Constants.THETA_S) { + System.out.println("Wieso solltest du zum selben Ort gehen wollen, an dem du eh schon bist???"); + endmenu(); + } + } //create a JFrame as my container for the simulation content private static void CreateFrame(ApplicationTime thread) {