-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFilmeVerwalter.java
More file actions
81 lines (65 loc) · 2.77 KB
/
FilmeVerwalter.java
File metadata and controls
81 lines (65 loc) · 2.77 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
import java.util.*;
public class FilmeVerwalter {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
int maxFilme = 6;
String[] titel = new String[maxFilme];
String[] regisseur = new String[maxFilme];
String[] hauptDarsteller = new String[maxFilme];
int[] erscheinungsjahr = new int[maxFilme];
int anzahlFilme = 0;
titel[0] = "Matrix 1";
regisseur[0] = "Wachowsky Brothers";
hauptDarsteller[0] = "Keanu";
erscheinungsjahr[0] = 1999;
titel[1] = "Matrix 2";
regisseur[1] = "Wachowsky Brothers";
hauptDarsteller[1] = "Keanu";
erscheinungsjahr[1] = 2003;
titel[2] = "Der Herr der Ringe";
regisseur[2] = "Peter Jackson";
hauptDarsteller[2] = "Viggo Mortensen";
erscheinungsjahr[2] = 2001;
titel[3] = "Paddington";
regisseur[3] = "?";
hauptDarsteller[3] = "Ben Wisher";
erscheinungsjahr[3] = 2017;
anzahlFilme = 4;
while (true) {
System.out.println("Gib den Titel des Films ein (oder 'exit' zum Beenden): ");
String filmTitel = scanner.nextLine();
if (filmTitel.equalsIgnoreCase("exit")) {
break;
}
System.out.println("Gib den Regisseur des Films ein: ");
String filmRegisseur = scanner.nextLine();
System.out.println("Gib den Hauptdarsteller des Films ein: ");
String filmHauptDarsteller = scanner.nextLine();
System.out.println("Gib das Erscheinungsjahr des Films ein: ");
int filmErscheinungsjahr = scanner.nextInt();
scanner.nextLine(); // Puffer leeren
// Film hinzufuegen
if (anzahlFilme < maxFilme) {
titel[anzahlFilme] = filmTitel;
regisseur[anzahlFilme] = filmRegisseur;
erscheinungsjahr[anzahlFilme] = filmErscheinungsjahr;
hauptDarsteller[anzahlFilme] = filmHauptDarsteller;
anzahlFilme++;
} else {
System.out.println("Die Filmesammlung ist voll!");
break;
}
}
// Alle Filme anzeigen
System.out.println("Filmesammlung:");
for (int i = 0; i < anzahlFilme; i++) {
System.out.println("Titel: " + titel[i] + ", Regisseur: " + regisseur[i] + ", Erscheinungsjahr: " +
erscheinungsjahr[i] + ", Hauptdarsteller: " + hauptDarsteller[i]);
}
scanner.close();
System.out.println(Arrays.toString(titel));
System.out.println(Arrays.toString(regisseur));
System.out.println(Arrays.toString(erscheinungsjahr));
System.out.println(Arrays.toString(hauptDarsteller));
}
}