First Commit
commit
2fce8f113a
|
@ -0,0 +1,10 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<classpath>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER">
|
||||
<attributes>
|
||||
<attribute name="module" value="true"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry kind="src" path="src"/>
|
||||
<classpathentry kind="output" path="bin"/>
|
||||
</classpath>
|
|
@ -0,0 +1 @@
|
|||
/bin/
|
|
@ -0,0 +1,17 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<projectDescription>
|
||||
<name>Semesteraufgabeee</name>
|
||||
<comment></comment>
|
||||
<projects>
|
||||
</projects>
|
||||
<buildSpec>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.jdt.core.javabuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
</buildSpec>
|
||||
<natures>
|
||||
<nature>org.eclipse.jdt.core.javanature</nature>
|
||||
</natures>
|
||||
</projectDescription>
|
|
@ -0,0 +1,2 @@
|
|||
eclipse.preferences.version=1
|
||||
encoding/<project>=UTF-8
|
|
@ -0,0 +1,134 @@
|
|||
import java.util.Random;
|
||||
import java.util.Scanner;
|
||||
|
||||
public class GeographieQuiz {
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
|
||||
Scanner scanner = new Scanner(System.in);
|
||||
Random random = new Random();
|
||||
|
||||
String[] easyQuestions = {"Was ist die Hauptstadt von Frankreich?", "Welcher Fluss fließt durch Berlin?",
|
||||
"In welchem Land liegt die Sahara-Wüste?", "Welche Ozean liegt östlich der Vereinigten Staaten",
|
||||
"Wie heisst der bevölkerungsreichste Kontinent"};
|
||||
String[] easyAnswers = {"Paris", "Spree", "Ägypten", "Atlantischer Ozean", "Asien"};
|
||||
String[] mediumQuestions = {"Welches Land wird als das Land der aufgehenden Sonne bezeichnet?",
|
||||
"Was ist der höchste Berg der Welt?", "Welcher Ozean liegt östlich von Australien?",
|
||||
"In welchem Land befindet sich der Kilimandscharo, der höchste Berg Afrikas", "Was ist der größte Fluss Europas"};
|
||||
String[] mediumAnswers = {"Japan", "Mount Everest", "Pazifik", "Tansania", "Wolga"};
|
||||
String[] hardQuestions = {"Was ist der längste Fluss der Welt?", "Welches Land hat die meisten Einwohner?",
|
||||
"Welches Land liegt sowohl in Europa als auch in Asien?", "Welcher See liegt in Afrika und ist der tiefste Süßwassersee der Welt",
|
||||
"Welche Inselgruppe bildet den südlichen Teil Italiens"};
|
||||
String[] hardAnswers = {"Amazonas", "China", "Russland", "Tanganjikasee", "Sizilien"};
|
||||
|
||||
|
||||
|
||||
String [] easyCapitalQuestions = {"Frankreich", "Deutschland", "USA", "Niederlande", "Spanien"};
|
||||
String [][] easyCapitalPossibleAnswers = {{"Paris", "Berlin", "Athen"},
|
||||
{"Amsterdam", "Madrid", "Berlin"},
|
||||
{"Ottawa","Rom","Washington D.C"}, {"Bruessel", "Kopenhagen", "Amsterdam"},
|
||||
{"Lissabon", "Barcelona", "Madrid"}};
|
||||
String [] easyCapitalAnswers = {"Paris", "Berlin", "Washington D.C", "Amsterdam", "Madrid"};
|
||||
|
||||
String [] mediumCapitalQuestions = {"Thailand", "Chile", "Kenia", "Bulgarien", "Argentinien"};
|
||||
String [][] mediumCapitalPossibleAnswers = {{"Bangkok", "Santiago", "Nairobi"},
|
||||
{"Bogota", "Buenos Aires", "Santiago"},
|
||||
{"Nairobi", "Kapstadt", "Canberra"}, {"Budapest", "Bukarest", "Sofia"},
|
||||
{"Lima", "Montevideo", "Buenos Aires"}};
|
||||
String [] mediumCapitalAnswers = {"Bangkok", "Santiago", "Nairobi", "Sofia", "Buenos Aires"};
|
||||
|
||||
String [] hardCapitalQuestions = {"Tansania", "Jamaika", "Äthiopien", "Malta", "Bangladesch"};
|
||||
String [][] hardCapitalPossibleAnswers = {{"Dodoma", "Kampala", "Eldoret"},
|
||||
{"Falmouth", "Kingston", "Morant Bay"},
|
||||
{"Mogadischu", "Ryadh", "Addid Abeba"}, {"Valletta", "Victoria", "Marsaskala"},
|
||||
{"Dhaka", "Guwahati", "Agartala"}};
|
||||
String [] hardCapitalAnswers = {"Dodoma", "Kingston", "Addid Abeba", "Valletta", "Dhaka"};
|
||||
|
||||
|
||||
|
||||
String [] longestRivers = {"Nil", "Amazonas", "Jangtse", "Mississippi", "Donau"};
|
||||
String [] biggestCountries = {"China", "Indien", "USA", "Indonesien", "Pakistan"};
|
||||
String [] biggestCities = {"Shanghai", "Delhi", "Karatschi", "Peking", "Shenzen"};
|
||||
String [] highestMountains = {"Mount Everest", "K2", "Kangchendzoenga", "Lhotse", "Makalu"};
|
||||
String [] biggestGPD = {"USA", "China", "Japan", "Deutschland", "Indien"};
|
||||
String [] highestLifeExpectancy = {"Monaco", "Japan", "Liechtenstein", "Hongkong", "Schweiz"};
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
System.out.println("Willkommen zum Geographie-Quiz");
|
||||
System.out.println("Waehlen Sie die Quizart aus \n1.Allgemeine Fragen\n2.Hauptstaedte\n3.Ranking");
|
||||
int auswahl = scanner.nextInt();
|
||||
if (auswahl > 3) {
|
||||
throw new Exception("Ungültige Eingabe");
|
||||
}
|
||||
System.out.println("Wählen Sie ihr Zeitlimit aus (Sekunden)");
|
||||
int zeitlimit = scanner.nextInt();
|
||||
|
||||
if (auswahl == 1) {
|
||||
System.out.println("Wählen Sie ihre Schwierigkeit aus \n1.Einfach\n2.Mittel\n3.Schwer");
|
||||
int antwort = scanner.nextInt();
|
||||
if (antwort > 3) {
|
||||
throw new Exception("Ungültige Eingabe");
|
||||
}
|
||||
|
||||
if (antwort == 1) {
|
||||
Tools.AllgemeinesQuizStarten(easyQuestions, easyAnswers, zeitlimit);
|
||||
}
|
||||
else if (antwort == 2) {
|
||||
Tools.AllgemeinesQuizStarten(mediumQuestions, mediumAnswers, zeitlimit);
|
||||
}
|
||||
else if (antwort == 3) {
|
||||
Tools.AllgemeinesQuizStarten(hardQuestions, hardAnswers, zeitlimit);
|
||||
}
|
||||
}
|
||||
|
||||
else if (auswahl == 2) {
|
||||
System.out.println("Wählen Sie ihre Schwierigkeit aus \n1.Einfach\n2.Mittel\n3.Schwer");
|
||||
int antwort = scanner.nextInt();
|
||||
if (antwort > 3) {
|
||||
throw new Exception("Ungültige Eingabe");
|
||||
}
|
||||
|
||||
if (antwort == 1) {
|
||||
Tools.HauptstadtQuizStarten(easyCapitalQuestions, easyCapitalPossibleAnswers, easyCapitalAnswers, zeitlimit);
|
||||
}
|
||||
else if (antwort == 2) {
|
||||
Tools.HauptstadtQuizStarten(mediumCapitalQuestions, mediumCapitalPossibleAnswers, mediumCapitalAnswers, zeitlimit);
|
||||
}
|
||||
else if (antwort == 3) {
|
||||
Tools.HauptstadtQuizStarten(hardCapitalQuestions, hardCapitalPossibleAnswers, hardCapitalAnswers, zeitlimit);
|
||||
}
|
||||
}
|
||||
else if (auswahl == 3) {
|
||||
System.out.println("Waehle eine Kategorie aus\n1.Flüsse\n2.Länder\n3.Städte\n4.Berge\n5.BIP\n6.Lebenserwartung");
|
||||
int kategorieAuswahl = scanner.nextInt();
|
||||
if (kategorieAuswahl > 6) {
|
||||
throw new Exception("Ungültige Eingabe");
|
||||
}
|
||||
|
||||
if (kategorieAuswahl == 1) {
|
||||
Tools.RankingQuizStarten(longestRivers, zeitlimit);
|
||||
}
|
||||
else if (kategorieAuswahl == 2) {
|
||||
Tools.RankingQuizStarten(biggestCountries, zeitlimit);
|
||||
}
|
||||
else if (kategorieAuswahl == 3) {
|
||||
Tools.RankingQuizStarten(biggestCities, zeitlimit);
|
||||
}
|
||||
else if (kategorieAuswahl == 4) {
|
||||
Tools.RankingQuizStarten(highestMountains, zeitlimit);
|
||||
}
|
||||
else if (kategorieAuswahl == 5) {
|
||||
Tools.RankingQuizStarten(biggestGPD, zeitlimit);
|
||||
}
|
||||
else if (kategorieAuswahl == 6) {
|
||||
Tools.RankingQuizStarten(highestLifeExpectancy, zeitlimit);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,197 @@
|
|||
import java.util.ArrayList;
|
||||
import java.util.Random;
|
||||
import java.util.Scanner;
|
||||
|
||||
public class Tools {
|
||||
//static Scanner scanner = new Scanner(System.in);
|
||||
private static int TIME_LIMIT_SECONDS = 10;
|
||||
private static final Scanner scanner = new Scanner(System.in);
|
||||
|
||||
public static void AllgemeinesQuizStarten(String [] questions, String [] answers, int zeitlimit) {
|
||||
|
||||
TIME_LIMIT_SECONDS = zeitlimit;
|
||||
int counter = 0;
|
||||
ArrayList<Integer>speicherArray = new ArrayList();
|
||||
|
||||
for (int i = 0; i < questions.length; i++) {
|
||||
int randomNumber;
|
||||
do {
|
||||
randomNumber = (int) (Math.random() * questions.length);
|
||||
} while (speicherArray.contains(randomNumber));
|
||||
|
||||
System.out.println(randomNumber);
|
||||
long startTime = System.currentTimeMillis();
|
||||
System.out.println(questions[randomNumber]);
|
||||
|
||||
//long startTime = System.currentTimeMillis();
|
||||
|
||||
String antwort = scanner.nextLine();
|
||||
long endTime = System.currentTimeMillis();
|
||||
|
||||
long elapsedTimeSeconds = (endTime - startTime) / 1000;
|
||||
|
||||
if (elapsedTimeSeconds > TIME_LIMIT_SECONDS) {
|
||||
System.out.println("Zeit abgelaufen! Die richtige Antwort war: " + answers[randomNumber]);
|
||||
} else {
|
||||
String korrekteAntwort = answers[randomNumber];
|
||||
if (antwort.equalsIgnoreCase(korrekteAntwort)) {
|
||||
System.out.println("Richtig");
|
||||
counter++;
|
||||
} else {
|
||||
System.out.println("Falsch. Die richtige Antwort war: " + korrekteAntwort);
|
||||
}
|
||||
}
|
||||
|
||||
speicherArray.add(randomNumber);
|
||||
}
|
||||
|
||||
System.out.printf("Sie haben von %d Fragen %d richtig beantwortet", questions.length, counter);
|
||||
|
||||
int j = 0;
|
||||
for (int i : speicherArray) {
|
||||
j++;
|
||||
System.out.println("\n");
|
||||
System.out.println(j + ".Frage: " + questions[i] + " \nAntwort: " + answers[i]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
public static void HauptstadtQuizStarten(String [] questions, String[][] possibleAnswers, String [] answers, int zeitlimit) throws Exception {
|
||||
|
||||
TIME_LIMIT_SECONDS = zeitlimit;
|
||||
int counter = 0;
|
||||
ArrayList<Integer> speicherArray = new ArrayList<>();
|
||||
int k;
|
||||
|
||||
for (int i = 0; i < questions.length; i++) {
|
||||
int randomNumber;
|
||||
do {
|
||||
randomNumber = (int) (Math.random() * questions.length);
|
||||
} while (speicherArray.contains(randomNumber));
|
||||
|
||||
System.out.println(randomNumber);
|
||||
long startTime = System.currentTimeMillis();
|
||||
System.out.println(questions[randomNumber]);
|
||||
|
||||
k = 0;
|
||||
for (int j = 0; j < possibleAnswers[randomNumber].length; j++) {
|
||||
k++;
|
||||
System.out.println(k + "." + possibleAnswers[randomNumber][j]);
|
||||
}
|
||||
|
||||
//long startTime = System.currentTimeMillis();
|
||||
int antwortIndex = scanner.nextInt();
|
||||
if (antwortIndex > 3) {
|
||||
throw new Exception("Ungültige Zahl");
|
||||
}
|
||||
long endTime = System.currentTimeMillis();
|
||||
|
||||
long elapsedTimeSeconds = (endTime - startTime) / 1000;
|
||||
|
||||
if (elapsedTimeSeconds > TIME_LIMIT_SECONDS) {
|
||||
System.out.println("Zeit abgelaufen! Die richtige Antwort war: " + answers[randomNumber]);
|
||||
} else {
|
||||
String antwort = possibleAnswers[randomNumber][antwortIndex - 1];
|
||||
String korrekteAntwort = answers[randomNumber];
|
||||
|
||||
if (antwort.equals(korrekteAntwort)) {
|
||||
System.out.println("Richtig");
|
||||
counter++;
|
||||
} else {
|
||||
System.out.println("Falsch. Die richtige Antwort war: " + korrekteAntwort);
|
||||
}
|
||||
}
|
||||
|
||||
speicherArray.add(randomNumber);
|
||||
}
|
||||
|
||||
System.out.printf("Sie haben von %d Fragen %d richtig beantwortet\n", questions.length, counter);
|
||||
|
||||
for (int i = 0; i< speicherArray.size(); i++) {
|
||||
System.out.println(i+1 + ".Frage: " + questions[speicherArray.get(i)]);
|
||||
System.out.println("Antwort: " + answers[speicherArray.get(i)] + "\n");
|
||||
}
|
||||
}
|
||||
|
||||
public static void RankingQuizStarten(String [] array, int zeitlimit) throws Exception {
|
||||
|
||||
TIME_LIMIT_SECONDS = zeitlimit;
|
||||
int randomNumber;
|
||||
long timeSum = 0;
|
||||
ArrayList<Integer>speicherArray = new ArrayList();
|
||||
ArrayList<String>eingabenArray = new ArrayList();
|
||||
for (int i = 0; i < array.length; i++) {
|
||||
eingabenArray.add(null);
|
||||
}
|
||||
|
||||
for (int i = 0; i<array.length; i++) {
|
||||
randomNumber = (int) (Math.random() * array.length);
|
||||
|
||||
if (!speicherArray.contains(randomNumber)) {
|
||||
System.out.println(array[randomNumber]);
|
||||
speicherArray.add(randomNumber);
|
||||
}
|
||||
else {
|
||||
i--;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//System.out.println(eingabenArray);
|
||||
long startTime = System.currentTimeMillis();
|
||||
for (int i : speicherArray) {
|
||||
|
||||
System.out.println("Geben Sie die Position von " + array[speicherArray.get(i)] + " ein: ");
|
||||
int eingabe = scanner.nextInt();
|
||||
if (eingabe > speicherArray.size()) {
|
||||
throw new Exception("Ungültige Eingabe");
|
||||
}
|
||||
eingabenArray.set(eingabe-1, array[speicherArray.get(i)]);
|
||||
//System.out.println(eingabenArray);
|
||||
long currentTime = System.currentTimeMillis();
|
||||
timeSum = (currentTime - startTime) / 1000;
|
||||
|
||||
if (timeSum > zeitlimit) {
|
||||
System.out.println("Zeit abgelaufen. Die Richtige Anordnung war:");
|
||||
|
||||
for (int j = 0; j < array.length; j++) {
|
||||
System.out.println(j+1 + "." + array[j]);
|
||||
|
||||
}
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
if (!(timeSum > zeitlimit)) {
|
||||
int counter = 0;
|
||||
for (int i = 0; i < eingabenArray.size(); i++) {
|
||||
//System.out.println(eingabenArray.get(i));
|
||||
//System.out.println(array[i]);
|
||||
if (eingabenArray.get(i).equals(array[i])) {
|
||||
counter++;
|
||||
}
|
||||
//System.out.println(counter);
|
||||
}
|
||||
|
||||
|
||||
if (counter == 5) {
|
||||
System.out.println("Richtig angeordnet");
|
||||
}
|
||||
|
||||
else {
|
||||
System.out.println("Falsch angeordnet");
|
||||
System.out.println("Richtige Anordnung: ");
|
||||
|
||||
for (int j = 0; j < array.length; j++) {
|
||||
System.out.println(j+1 + "." + array[j]);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue