initial commit
This commit is contained in:
commit
ef8d621a58
|
|
@ -0,0 +1,8 @@
|
|||
# Default ignored files
|
||||
/shelf/
|
||||
/workspace.xml
|
||||
# Datasource local storage ignored files
|
||||
/dataSources/
|
||||
/dataSources.local.xml
|
||||
# Editor-based HTTP Client requests
|
||||
/httpRequests/
|
||||
|
|
@ -0,0 +1 @@
|
|||
<html>Simple <b>Java</b> application that includes a class with <code>main()</code> method</html>
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="Encoding">
|
||||
<file url="PROJECT" charset="UTF-8" />
|
||||
</component>
|
||||
</project>
|
||||
|
|
@ -0,0 +1,10 @@
|
|||
<component name="InspectionProjectProfileManager">
|
||||
<profile version="1.0">
|
||||
<option name="myName" value="Project Default" />
|
||||
<inspection_tool class="SpellCheckingInspection" enabled="false" level="TYPO" enabled_by_default="false">
|
||||
<option name="processCode" value="true" />
|
||||
<option name="processLiterals" value="true" />
|
||||
<option name="processComments" value="true" />
|
||||
</inspection_tool>
|
||||
</profile>
|
||||
</component>
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ProjectKey">
|
||||
<option name="state" value="project://e2804f05-5315-4fc6-a121-c522a6c26470" />
|
||||
</component>
|
||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_13" default="true" project-jdk-name="13" project-jdk-type="JavaSDK">
|
||||
<output url="file://$PROJECT_DIR$/out" />
|
||||
</component>
|
||||
</project>
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ProjectModuleManager">
|
||||
<modules>
|
||||
<module fileurl="file://$PROJECT_DIR$/Kino.iml" filepath="$PROJECT_DIR$/Kino.iml" />
|
||||
</modules>
|
||||
</component>
|
||||
</project>
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
<template>
|
||||
<input-field default="com.company">IJ_BASE_PACKAGE</input-field>
|
||||
</template>
|
||||
|
|
@ -0,0 +1,124 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="Palette2">
|
||||
<group name="Swing">
|
||||
<item class="com.intellij.uiDesigner.HSpacer" tooltip-text="Horizontal Spacer" icon="/com/intellij/uiDesigner/icons/hspacer.png" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||
<default-constraints vsize-policy="1" hsize-policy="6" anchor="0" fill="1" />
|
||||
</item>
|
||||
<item class="com.intellij.uiDesigner.VSpacer" tooltip-text="Vertical Spacer" icon="/com/intellij/uiDesigner/icons/vspacer.png" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||
<default-constraints vsize-policy="6" hsize-policy="1" anchor="0" fill="2" />
|
||||
</item>
|
||||
<item class="javax.swing.JPanel" icon="/com/intellij/uiDesigner/icons/panel.png" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||
<default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3" />
|
||||
</item>
|
||||
<item class="javax.swing.JScrollPane" icon="/com/intellij/uiDesigner/icons/scrollPane.png" removable="false" auto-create-binding="false" can-attach-label="true">
|
||||
<default-constraints vsize-policy="7" hsize-policy="7" anchor="0" fill="3" />
|
||||
</item>
|
||||
<item class="javax.swing.JButton" icon="/com/intellij/uiDesigner/icons/button.png" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="0" hsize-policy="3" anchor="0" fill="1" />
|
||||
<initial-values>
|
||||
<property name="text" value="Button" />
|
||||
</initial-values>
|
||||
</item>
|
||||
<item class="javax.swing.JRadioButton" icon="/com/intellij/uiDesigner/icons/radioButton.png" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="0" hsize-policy="3" anchor="8" fill="0" />
|
||||
<initial-values>
|
||||
<property name="text" value="RadioButton" />
|
||||
</initial-values>
|
||||
</item>
|
||||
<item class="javax.swing.JCheckBox" icon="/com/intellij/uiDesigner/icons/checkBox.png" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="0" hsize-policy="3" anchor="8" fill="0" />
|
||||
<initial-values>
|
||||
<property name="text" value="CheckBox" />
|
||||
</initial-values>
|
||||
</item>
|
||||
<item class="javax.swing.JLabel" icon="/com/intellij/uiDesigner/icons/label.png" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||
<default-constraints vsize-policy="0" hsize-policy="0" anchor="8" fill="0" />
|
||||
<initial-values>
|
||||
<property name="text" value="Label" />
|
||||
</initial-values>
|
||||
</item>
|
||||
<item class="javax.swing.JTextField" icon="/com/intellij/uiDesigner/icons/textField.png" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
|
||||
<preferred-size width="150" height="-1" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JPasswordField" icon="/com/intellij/uiDesigner/icons/passwordField.png" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
|
||||
<preferred-size width="150" height="-1" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JFormattedTextField" icon="/com/intellij/uiDesigner/icons/formattedTextField.png" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
|
||||
<preferred-size width="150" height="-1" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JTextArea" icon="/com/intellij/uiDesigner/icons/textArea.png" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
|
||||
<preferred-size width="150" height="50" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JTextPane" icon="/com/intellij/uiDesigner/icons/textPane.png" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
|
||||
<preferred-size width="150" height="50" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JEditorPane" icon="/com/intellij/uiDesigner/icons/editorPane.png" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
|
||||
<preferred-size width="150" height="50" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JComboBox" icon="/com/intellij/uiDesigner/icons/comboBox.png" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||
<default-constraints vsize-policy="0" hsize-policy="2" anchor="8" fill="1" />
|
||||
</item>
|
||||
<item class="javax.swing.JTable" icon="/com/intellij/uiDesigner/icons/table.png" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
|
||||
<preferred-size width="150" height="50" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JList" icon="/com/intellij/uiDesigner/icons/list.png" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="6" hsize-policy="2" anchor="0" fill="3">
|
||||
<preferred-size width="150" height="50" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JTree" icon="/com/intellij/uiDesigner/icons/tree.png" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
|
||||
<preferred-size width="150" height="50" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JTabbedPane" icon="/com/intellij/uiDesigner/icons/tabbedPane.png" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3">
|
||||
<preferred-size width="200" height="200" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JSplitPane" icon="/com/intellij/uiDesigner/icons/splitPane.png" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||
<default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3">
|
||||
<preferred-size width="200" height="200" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JSpinner" icon="/com/intellij/uiDesigner/icons/spinner.png" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1" />
|
||||
</item>
|
||||
<item class="javax.swing.JSlider" icon="/com/intellij/uiDesigner/icons/slider.png" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1" />
|
||||
</item>
|
||||
<item class="javax.swing.JSeparator" icon="/com/intellij/uiDesigner/icons/separator.png" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3" />
|
||||
</item>
|
||||
<item class="javax.swing.JProgressBar" icon="/com/intellij/uiDesigner/icons/progressbar.png" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="0" hsize-policy="6" anchor="0" fill="1" />
|
||||
</item>
|
||||
<item class="javax.swing.JToolBar" icon="/com/intellij/uiDesigner/icons/toolbar.png" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||
<default-constraints vsize-policy="0" hsize-policy="6" anchor="0" fill="1">
|
||||
<preferred-size width="-1" height="20" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JToolBar$Separator" icon="/com/intellij/uiDesigner/icons/toolbarSeparator.png" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||
<default-constraints vsize-policy="0" hsize-policy="0" anchor="0" fill="1" />
|
||||
</item>
|
||||
<item class="javax.swing.JScrollBar" icon="/com/intellij/uiDesigner/icons/scrollbar.png" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="6" hsize-policy="0" anchor="0" fill="2" />
|
||||
</item>
|
||||
</group>
|
||||
</component>
|
||||
</project>
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 374 KiB |
|
|
@ -0,0 +1,24 @@
|
|||
package gfn.marc;
|
||||
|
||||
public class Sitzplatz {
|
||||
|
||||
private final int nummer;
|
||||
private boolean status; // true wenn frei, false wenn belegt
|
||||
|
||||
public Sitzplatz(int nummer, boolean status) {
|
||||
this.nummer = nummer;
|
||||
this.status = status;
|
||||
}
|
||||
|
||||
public int getNummer() {
|
||||
return nummer;
|
||||
}
|
||||
|
||||
public boolean isStatus() {
|
||||
return status;
|
||||
}
|
||||
|
||||
public void setStatus(boolean status) {
|
||||
this.status = status;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,155 @@
|
|||
package gfn.marc.version1;
|
||||
|
||||
/*
|
||||
Version 1: "normale" Arrays
|
||||
*/
|
||||
|
||||
import gfn.marc.Sitzplatz;
|
||||
|
||||
import java.util.InputMismatchException;
|
||||
import java.util.Scanner;
|
||||
|
||||
public class Main_v1 {
|
||||
|
||||
// VORBEREITUNG
|
||||
// Array für Sitzplan erstellen
|
||||
static Sitzplatz[][] sitzplan = new Sitzplatz[7][30];
|
||||
|
||||
public static void main(String[] args) {
|
||||
|
||||
// Sitzplan-Array füllen
|
||||
for (int i = 0; i < sitzplan.length; i++) {
|
||||
for (int j = 0; j < sitzplan[i].length; j++) {
|
||||
sitzplan[i][j] = new Sitzplatz(((i + 1) * 100 + (j + 1)), false);
|
||||
}
|
||||
}
|
||||
|
||||
// Hilfs-Array für freie Plätze (wie in der Vorgabe)
|
||||
int[] alleFreienSitzplaetze = {102, 203, 204, 207, 208, 209, 303, 304, 305, 306, 307, 308};
|
||||
|
||||
// Freie Plätze in Sitzplan-Array eintragen
|
||||
try {
|
||||
for (int sitzplatz : alleFreienSitzplaetze) {
|
||||
int i = (sitzplatz / 100) - 1;
|
||||
int j = (sitzplatz % 10) - 1;
|
||||
sitzplan[i][j].setStatus(true);
|
||||
}
|
||||
} catch (ArrayIndexOutOfBoundsException aioobe) {
|
||||
System.err.println("Fehlerhafte Sitzplatznummer in Array \"alleFreienSitzplaetze\" eingetragen!");
|
||||
System.exit(0);
|
||||
}
|
||||
|
||||
// LÖSUNG
|
||||
// Gewünschte Sitzplatzanzahl eingeben
|
||||
boolean reservierung = true;
|
||||
Scanner eingabe = new Scanner(System.in);
|
||||
int anzahlSitze = 0;
|
||||
System.out.println("Bitte geben Sie die gewünschte Anzahl von Sitzplätzen ein! (1 - 30)");
|
||||
|
||||
// Eingabe überprüfen
|
||||
while (true) {
|
||||
try {
|
||||
anzahlSitze = eingabe.nextInt();
|
||||
if (anzahlSitze < 1 || anzahlSitze > 30) {
|
||||
System.err.println("Die eingegebene Zahl ist ungültig!");
|
||||
System.err.println("Bitte geben Sie eine Zahl zwischen 1 und 30 ein.");
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
} catch (InputMismatchException ime) {
|
||||
System.err.println("Bitte geben Sie eine Zahl ein!");
|
||||
eingabe.next();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// Freie Sitzplätze mit der Methode freieSitze() ermitteln
|
||||
int freierSitzplatz = freieSitze(anzahlSitze);
|
||||
|
||||
// Ausgabe der Nummern der freien Sitzplätze
|
||||
if (freierSitzplatz != 0 && anzahlSitze > 1) {
|
||||
System.out.print("Folgende Sitzplätze können für Sie reserviert werden: ");
|
||||
for (int i = 0; i < anzahlSitze; i++) {
|
||||
if (i < anzahlSitze - 1) {
|
||||
System.out.print(freierSitzplatz + i + ", ");
|
||||
} else {
|
||||
System.out.print(freierSitzplatz + i);
|
||||
}
|
||||
}
|
||||
System.out.println();
|
||||
} else if (freierSitzplatz != 0) {
|
||||
System.out.println("Folgender Sitzplatz kann für Sie reserviert werden: " + freierSitzplatz);
|
||||
|
||||
// Falls gewünschte Anzahl von freien Sitzplätzen nicht vorhanden
|
||||
} else {
|
||||
System.out.println(anzahlSitze > 1 ? "Leider konnten wir für Sie nicht die gewünschte Anzahl freier " +
|
||||
"Sitzplätze reservieren." : "Leider haben wir derzeit keinen freien Sitzplatz.");
|
||||
reservierung = false;
|
||||
}
|
||||
|
||||
// Abfrage "Möchten Sie reservieren?" mit Überprüfung der Eingabe
|
||||
while (reservierung) {
|
||||
System.out.println("Möchten Sie reservieren? (j/n)");
|
||||
String auswahl = eingabe.next().trim().toLowerCase();
|
||||
|
||||
// Wenn ja ("j")
|
||||
if (auswahl.matches("j")) {
|
||||
|
||||
for (int i = 0; i < anzahlSitze; i++) {
|
||||
for (int j = 0; j < sitzplan.length; j++) {
|
||||
for (int k = 0; k < sitzplan[i].length; k++) {
|
||||
if (freierSitzplatz + i == sitzplan[j][k].getNummer()) {
|
||||
sitzplan[j][k].setStatus(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
System.out.println(anzahlSitze > 1 ? "Die Sitzplätze wurden für Sie reserviert!" :
|
||||
"Der Sitzplatz wurde für Sie reserviert!");
|
||||
|
||||
reservierung = false;
|
||||
|
||||
// Wenn nein ("n")
|
||||
} else if (auswahl.matches("n")) {
|
||||
reservierung = false;
|
||||
|
||||
// Wenn Eingabe ungültig
|
||||
} else {
|
||||
System.err.println("Eingabe ungültig!");
|
||||
}
|
||||
}
|
||||
|
||||
System.out.println("Vielen Dannk für Ihren Besuch und auf Wiedersehen!");
|
||||
|
||||
// Übrige freie Sitzplätze
|
||||
System.out.println("\nÜbrige freie Sitzplätze: ");
|
||||
for (int i = 0; i < sitzplan.length; i++) {
|
||||
for (int j = 0; j < sitzplan[i].length; j++) {
|
||||
if (sitzplan[i][j].isStatus()) {
|
||||
System.out.print(sitzplan[i][j].getNummer() + " ");
|
||||
}
|
||||
}
|
||||
}
|
||||
System.out.println();
|
||||
|
||||
}
|
||||
|
||||
static int freieSitze(int anzahlSitze) {
|
||||
int zaehler = 0;
|
||||
for (int i = 0; i < sitzplan.length; i++) {
|
||||
for (int j = 0; j < sitzplan[i].length; j++) {
|
||||
if (sitzplan[i][j].isStatus()) {
|
||||
zaehler++;
|
||||
} else {
|
||||
zaehler = 0;
|
||||
}
|
||||
if (zaehler >= anzahlSitze) {
|
||||
return sitzplan[i][j - (zaehler - 1)].getNummer();
|
||||
}
|
||||
}
|
||||
zaehler = 0;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,143 @@
|
|||
package gfn.marc.version2;
|
||||
|
||||
/*
|
||||
Version 2: ArrayLists
|
||||
*/
|
||||
|
||||
import gfn.marc.Sitzplatz;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
public class Main_v2 {
|
||||
|
||||
// VORBEREITUNG
|
||||
// ArrayList für Sitzplan erstellen
|
||||
static ArrayList<Sitzplatz> sitzplan = new ArrayList<>(210);
|
||||
|
||||
public static void main(String[] args) {
|
||||
|
||||
// Sitzplan-ArrayList füllen
|
||||
for (int i = 0; i < 7; i++) {
|
||||
for (int j = 0; j < 30; j++) {
|
||||
sitzplan.add(new Sitzplatz(((i + 1) * 100 + (j + 1)), false));
|
||||
}
|
||||
}
|
||||
|
||||
// Hilfs-HashSet für freie Plätze (wie in der Vorgabe)
|
||||
HashSet<Integer> alleFreienSitzplaetze = new HashSet<Integer>
|
||||
(Arrays.asList(102, 203, 204, 207, 208, 209, 303, 304, 305, 306, 307, 308));
|
||||
|
||||
// Freie Plätze in Sitzplan-Array eintragen
|
||||
for (Sitzplatz sitzplatz : sitzplan) {
|
||||
if (alleFreienSitzplaetze.contains(sitzplatz.getNummer())) {
|
||||
sitzplatz.setStatus(true);
|
||||
}
|
||||
}
|
||||
|
||||
// LÖSUNG
|
||||
// Gewünschte Sitzplatzanzahl eingeben
|
||||
boolean reservierung = true;
|
||||
Scanner eingabe = new Scanner(System.in);
|
||||
int anzahlSitze = 0;
|
||||
System.out.println("Bitte geben Sie die gewünschte Anzahl von Sitzplätzen ein! (1 - 30)");
|
||||
|
||||
// Eingabe überprüfen
|
||||
while (true) {
|
||||
try {
|
||||
anzahlSitze = eingabe.nextInt();
|
||||
if (anzahlSitze < 1 || anzahlSitze > 30) {
|
||||
System.err.println("Die eingegebene Zahl ist ungültig!");
|
||||
System.err.println("Bitte geben Sie eine Zahl zwischen 1 und 30 ein.");
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
} catch (InputMismatchException ime) {
|
||||
System.err.println("Bitte geben Sie eine Zahl ein!");
|
||||
eingabe.next();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// Freie Sitzplätze mit der Methode freieSitze() ermitteln
|
||||
int freierSitzplatz = freieSitze(anzahlSitze);
|
||||
|
||||
// Ausgabe der Nummern der freien Sitzplätze
|
||||
if (freierSitzplatz != 0 && anzahlSitze > 1) {
|
||||
System.out.print("Folgende Sitzplätze können für Sie reserviert werden: ");
|
||||
for (int i = 0; i < anzahlSitze; i++) {
|
||||
if (i < anzahlSitze - 1) {
|
||||
System.out.print(freierSitzplatz + i + ", ");
|
||||
} else {
|
||||
System.out.print(freierSitzplatz + i);
|
||||
}
|
||||
}
|
||||
System.out.println();
|
||||
} else if (freierSitzplatz != 0) {
|
||||
System.out.println("Folgender Sitzplatz kann für Sie reserviert werden: " + freierSitzplatz);
|
||||
|
||||
// Falls gewünschte Anzahl von freien Sitzplätzen nicht vorhanden
|
||||
} else {
|
||||
System.out.println(anzahlSitze > 1 ? "Leider konnten wir für Sie nicht die gewünschte Anzahl freier " +
|
||||
"Sitzplätze reservieren." : "Leider haben wir derzeit keinen freien Sitzplatz.");
|
||||
reservierung = false;
|
||||
}
|
||||
|
||||
// Abfrage "Möchten Sie reservieren?" mit Überprüfung der Eingabe
|
||||
while (reservierung) {
|
||||
System.out.println("Möchten Sie reservieren? (j/n)");
|
||||
String auswahl = eingabe.next().trim().toLowerCase();
|
||||
|
||||
// Wenn ja ("j")
|
||||
if (auswahl.matches("j")) {
|
||||
|
||||
for (int i = 0; i < anzahlSitze; i++) {
|
||||
for (Sitzplatz sitzplatz : sitzplan) {
|
||||
if (freierSitzplatz + i == sitzplatz.getNummer()) {
|
||||
sitzplatz.setStatus(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
System.out.println(anzahlSitze > 1 ? "Die Sitzplätze wurden für Sie reserviert!" :
|
||||
"Der Sitzplatz wurde für Sie reserviert!");
|
||||
|
||||
reservierung = false;
|
||||
|
||||
// Wenn nein ("n")
|
||||
} else if (auswahl.matches("n")) {
|
||||
reservierung = false;
|
||||
|
||||
// Wenn Eingabe ungültig
|
||||
} else {
|
||||
System.err.println("Eingabe ungültig!");
|
||||
}
|
||||
}
|
||||
|
||||
System.out.println("Vielen Dannk für Ihren Besuch und auf Wiedersehen!");
|
||||
|
||||
// OpÜbrige freie Sitzplätze
|
||||
System.out.println("\nÜbrige freie Sitzplätze: ");
|
||||
for (Sitzplatz sitzplatz : sitzplan) {
|
||||
if (sitzplatz.isStatus()) {
|
||||
System.out.print(sitzplatz.getNummer() + " ");
|
||||
}
|
||||
}
|
||||
System.out.println();
|
||||
|
||||
}
|
||||
|
||||
static int freieSitze(int anzahlSitze) {
|
||||
int zaehler = 0;
|
||||
for (int i = 0; i < sitzplan.size(); i++) {
|
||||
if (sitzplan.get(i).isStatus()) {
|
||||
zaehler++;
|
||||
} else {
|
||||
zaehler = 0;
|
||||
}
|
||||
if (zaehler == anzahlSitze) {
|
||||
return sitzplan.get(i - (zaehler - 1)).getNummer();
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue