jooo
parent
163d6ed519
commit
9f5a94d75f
|
@ -1,9 +1,5 @@
|
|||
import java.io.BufferedWriter;
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.FileWriter;
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStreamWriter;
|
||||
import java.io.PrintWriter;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
|
@ -17,7 +13,7 @@ public class User {
|
|||
public String name;
|
||||
public double bmi = gewicht / (koerpergroesse * koerpergroesse);
|
||||
public double ziel;
|
||||
public ArrayList<Integer> streckenListe = new ArrayList<>();
|
||||
public static ArrayList<Integer> streckenListe = new ArrayList<>();
|
||||
public static HashMap<String, User> userListe = new HashMap<>();
|
||||
|
||||
//globaler Scanner
|
||||
|
@ -79,41 +75,41 @@ public class User {
|
|||
} else {
|
||||
System.out.println("Schade! Aber nicht aufgeben!");
|
||||
}
|
||||
//User.speichereStrecke((int)strecke);
|
||||
}
|
||||
|
||||
// Methode
|
||||
public static void speichereStrecke(int strecke) throws IOException {
|
||||
strecke = Integer.parseInt(sc.nextLine());
|
||||
//PrintWriter streckeimMonat = new PrintWriter(new FileWriter("src/monatsliste.txt", true), true);
|
||||
//FileWriter streckeimMonat = new FileWriter("src/monatsliste.txt", true);
|
||||
//File file = new File("src/monatsliste.txt");
|
||||
//BufferedWriter streckeimMonat = new BufferedWriter(new FileWriter(file, true));
|
||||
FileWriter streckeimMonat = new FileWriter ("src/monatsliste.txt");
|
||||
streckeimMonat.write(strecke);
|
||||
PrintWriter streckeimMonat = new PrintWriter(new FileWriter("src/monatsliste.txt", true), true);
|
||||
streckeimMonat.write(input[0]+"\n");
|
||||
streckeimMonat.close();
|
||||
|
||||
User.ermittleLaengsteStrecke();
|
||||
}
|
||||
|
||||
|
||||
|
||||
// Methode
|
||||
public void fügeindieArrayList() throws Exception {
|
||||
public static void fügeindieArrayList() throws Exception {
|
||||
|
||||
Scanner sc = new Scanner(new File("src/monatsliste.txt"));
|
||||
while (sc.hasNext()) {
|
||||
try {
|
||||
streckenListe.add(Integer.parseInt(sc.nextLine()));
|
||||
} catch (NumberFormatException e) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Methode
|
||||
public void ermittleLaengsteStrecke() throws Exception {
|
||||
public static void ermittleLaengsteStrecke() throws Exception {
|
||||
|
||||
fügeindieArrayList();
|
||||
//User u = null;
|
||||
User.fügeindieArrayList();
|
||||
double laengsteStrecke = 0;
|
||||
for (int i = 0; i <= streckenListe.size(); i++) {
|
||||
for (int i = 0; i <streckenListe.size(); i++) {
|
||||
if (streckenListe.get(i) > laengsteStrecke) {
|
||||
laengsteStrecke = streckenListe.get(i);
|
||||
}
|
||||
}
|
||||
System.out.printf("Die laengste Strecke bis jetzt ist %f", laengsteStrecke);
|
||||
System.out.printf("Die laengste Strecke bis jetzt ist %.2f km. Weiter so!", laengsteStrecke);
|
||||
System.out.println();
|
||||
}
|
||||
|
||||
// Methode
|
||||
|
@ -132,7 +128,6 @@ public class User {
|
|||
return kalorienverbrauch;
|
||||
}
|
||||
|
||||
|
||||
// Methode
|
||||
/*
|
||||
* public void angabenändern() {
|
||||
|
@ -143,6 +138,17 @@ public class User {
|
|||
*
|
||||
* }
|
||||
* }
|
||||
*
|
||||
* // Methode brauche ich nicht mehr
|
||||
public static void speichereStrecke() throws IOException {
|
||||
String strecke = sc.nextLine();
|
||||
|
||||
//FileWriter streckeimMonat = new FileWriter("src/monatsliste.txt", true);
|
||||
//File file = new File("src/monatsliste.txt");
|
||||
//BufferedWriter streckeimMonat = new BufferedWriter(new FileWriter(file, true));
|
||||
//FileWriter streckeimMonat = new FileWriter ("src/monatsliste.txt");
|
||||
|
||||
}
|
||||
*/
|
||||
|
||||
}
|
||||
|
|
|
@ -1 +1,7 @@
|
|||
|
||||
45
|
||||
45
|
||||
32
|
||||
34
|
||||
12
|
||||
50
|
||||
|
|
|
@ -17,7 +17,7 @@ public class userinterface {
|
|||
User.eingabeSession();
|
||||
System.out.println();
|
||||
} else if (antwort[0].equalsIgnoreCase("Ziel")) {
|
||||
User.speichereStrecke(0);
|
||||
|
||||
} else if (antwort[1].equalsIgnoreCase("beenden")) {
|
||||
System.out.println("Bis zum nächsten Mal!");
|
||||
break;
|
||||
|
|
Loading…
Reference in New Issue