changed how program handles dates and added search tab
parent
8b1904c138
commit
462242c4e4
|
@ -80,6 +80,11 @@ public class Bibliothek {
|
||||||
Kunde k3 = new Kunde(false, 3);
|
Kunde k3 = new Kunde(false, 3);
|
||||||
Kunde k4 = new Kunde(false, 4);
|
Kunde k4 = new Kunde(false, 4);
|
||||||
Kunde k5 = new Kunde(false, 5);
|
Kunde k5 = new Kunde(false, 5);
|
||||||
|
k1.addSchulden(5);
|
||||||
|
k2.addSchulden(5);
|
||||||
|
k3.addSchulden(10);
|
||||||
|
k4.addSchulden(10);
|
||||||
|
k5.addSchulden(10);
|
||||||
kundenListe.add(k1);
|
kundenListe.add(k1);
|
||||||
kundenListe.add(k2);
|
kundenListe.add(k2);
|
||||||
kundenListe.add(k3);
|
kundenListe.add(k3);
|
||||||
|
@ -279,10 +284,12 @@ public class Bibliothek {
|
||||||
Buch b = (Buch) m;
|
Buch b = (Buch) m;
|
||||||
double kostenBuch = berechneGebühren(b, kennnummer, rückgabeDatum);
|
double kostenBuch = berechneGebühren(b, kennnummer, rückgabeDatum);
|
||||||
String titelBuch = b.getTitel();
|
String titelBuch = b.getTitel();
|
||||||
if(kostenBuch>0) {BibliothekGUI.zahlungsFenster(kostenBuch, titelBuch, kennnummer, k);
|
if(kostenBuch > 0) {
|
||||||
bücherListe.add(b);
|
|
||||||
k.removeFromList(m);
|
k.removeFromList(m);
|
||||||
} else {
|
BibliothekGUI.zahlungsFenster(kostenBuch, titelBuch, kennnummer, k);
|
||||||
|
k.addSchulden(kostenBuch);
|
||||||
|
bücherListe.add(b);
|
||||||
|
} else if(kostenBuch == 0){
|
||||||
bücherListe.add(b);
|
bücherListe.add(b);
|
||||||
k.removeFromList(m);
|
k.removeFromList(m);
|
||||||
BibliothekGUI.noMoneyOwed();
|
BibliothekGUI.noMoneyOwed();
|
||||||
|
@ -292,9 +299,10 @@ public class Bibliothek {
|
||||||
DVD d = (DVD) m;
|
DVD d = (DVD) m;
|
||||||
double kostenDVD = berechneGebühren(d, kennnummer, rückgabeDatum);
|
double kostenDVD = berechneGebühren(d, kennnummer, rückgabeDatum);
|
||||||
String titelDVD = d.getTitel();
|
String titelDVD = d.getTitel();
|
||||||
if(kostenDVD>0) {BibliothekGUI.zahlungsFenster(kostenDVD, titelDVD, kennnummer, k);
|
|
||||||
dvdListe.add(d);
|
|
||||||
k.removeFromList(m);
|
k.removeFromList(m);
|
||||||
|
if(kostenDVD>0) {BibliothekGUI.zahlungsFenster(kostenDVD, titelDVD, kennnummer, k);
|
||||||
|
k.addSchulden(kostenDVD);
|
||||||
|
dvdListe.add(d);
|
||||||
} else {
|
} else {
|
||||||
dvdListe.add(d);
|
dvdListe.add(d);
|
||||||
k.removeFromList(m);
|
k.removeFromList(m);
|
||||||
|
@ -305,9 +313,10 @@ public class Bibliothek {
|
||||||
CD c = (CD) m;
|
CD c = (CD) m;
|
||||||
double kostenCD = berechneGebühren(c, kennnummer, rückgabeDatum);
|
double kostenCD = berechneGebühren(c, kennnummer, rückgabeDatum);
|
||||||
String titelCD = c.getTitel();
|
String titelCD = c.getTitel();
|
||||||
if(kostenCD>0) {BibliothekGUI.zahlungsFenster(kostenCD, titelCD, kennnummer, k);
|
|
||||||
cdListe.add(c);
|
|
||||||
k.removeFromList(m);
|
k.removeFromList(m);
|
||||||
|
if(kostenCD>0) {BibliothekGUI.zahlungsFenster(kostenCD, titelCD, kennnummer, k);
|
||||||
|
k.addSchulden(kostenCD);
|
||||||
|
cdListe.add(c);
|
||||||
} else {
|
} else {
|
||||||
cdListe.add(c);
|
cdListe.add(c);
|
||||||
k.removeFromList(m);
|
k.removeFromList(m);
|
||||||
|
@ -318,9 +327,10 @@ public class Bibliothek {
|
||||||
Brettspiel bs = (Brettspiel) m;
|
Brettspiel bs = (Brettspiel) m;
|
||||||
double kostenBS = berechneGebühren(bs, kennnummer, rückgabeDatum);
|
double kostenBS = berechneGebühren(bs, kennnummer, rückgabeDatum);
|
||||||
String titelBS = bs.getTitel();
|
String titelBS = bs.getTitel();
|
||||||
if(kostenBS>0) {BibliothekGUI.zahlungsFenster(kostenBS, titelBS, kennnummer, k);
|
|
||||||
brettspielListe.add(bs);
|
|
||||||
k.removeFromList(m);
|
k.removeFromList(m);
|
||||||
|
if(kostenBS>0) {BibliothekGUI.zahlungsFenster(kostenBS, titelBS, kennnummer, k);
|
||||||
|
k.addSchulden(kostenBS);
|
||||||
|
brettspielListe.add(bs);
|
||||||
} else {
|
} else {
|
||||||
brettspielListe.add(bs);
|
brettspielListe.add(bs);
|
||||||
k.removeFromList(m);
|
k.removeFromList(m);
|
||||||
|
@ -331,9 +341,10 @@ public class Bibliothek {
|
||||||
Videospiel vs = (Videospiel) m;
|
Videospiel vs = (Videospiel) m;
|
||||||
double kostenVS = berechneGebühren(vs, kennnummer, rückgabeDatum);
|
double kostenVS = berechneGebühren(vs, kennnummer, rückgabeDatum);
|
||||||
String titelVS = vs.getTitel();
|
String titelVS = vs.getTitel();
|
||||||
if(kostenVS>0) {BibliothekGUI.zahlungsFenster(kostenVS, titelVS, kennnummer, k);
|
|
||||||
videospielListe.add(vs);
|
|
||||||
k.removeFromList(m);
|
k.removeFromList(m);
|
||||||
|
if(kostenVS>0) {BibliothekGUI.zahlungsFenster(kostenVS, titelVS, kennnummer, k);
|
||||||
|
k.addSchulden(kostenVS);
|
||||||
|
videospielListe.add(vs);
|
||||||
} else {
|
} else {
|
||||||
videospielListe.add(vs);
|
videospielListe.add(vs);
|
||||||
k.removeFromList(m);
|
k.removeFromList(m);
|
||||||
|
@ -535,6 +546,7 @@ public class Bibliothek {
|
||||||
ArrayList<Medium> ausgeliehenListe = k.returnAusgelieheneMedien();
|
ArrayList<Medium> ausgeliehenListe = k.returnAusgelieheneMedien();
|
||||||
for(Medium m: ausgeliehenListe) {
|
for(Medium m: ausgeliehenListe) {
|
||||||
if(m.getKennnummer() == kennnummer) {
|
if(m.getKennnummer() == kennnummer) {
|
||||||
|
|
||||||
if(m.getVerlängerungen() > 0) {
|
if(m.getVerlängerungen() > 0) {
|
||||||
m.setVerlängerung();
|
m.setVerlängerung();
|
||||||
datumVerlängern(m, k);
|
datumVerlängern(m, k);
|
||||||
|
@ -568,6 +580,144 @@ public class Bibliothek {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static Kunde findKunde(int kennnummer) {
|
||||||
|
for(Kunde k: kundenListe) {
|
||||||
|
ArrayList<Medium> ausgelieheneMedienVonKunde = k.returnAusgelieheneMedien();
|
||||||
|
for(Medium m: ausgelieheneMedienVonKunde) {
|
||||||
|
if(m.getKennnummer() == kennnummer) {
|
||||||
|
return k;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void rückgabe2(int kennnummer, String rückgabeDatum, Kunde k) {
|
||||||
|
for(Medium m: katalog) {
|
||||||
|
if(m.getKennnummer() == kennnummer) {
|
||||||
|
String text = m.getClass().toString();
|
||||||
|
int lastDotIndex = text.lastIndexOf(".");
|
||||||
|
String substring = text.substring(lastDotIndex + 1);
|
||||||
|
switch (substring) {
|
||||||
|
case "Buch":
|
||||||
|
Buch b = (Buch) m;
|
||||||
|
double kostenBuch = berechneGebühren(b, kennnummer, rückgabeDatum);
|
||||||
|
String titelBuch = b.getTitel();
|
||||||
|
if(kostenBuch > 0) {
|
||||||
|
BibliothekGUI.zahlungsFenster2(kostenBuch, titelBuch, kennnummer, k);
|
||||||
|
k.addSchulden(kostenBuch);
|
||||||
|
bücherListe.add(b);
|
||||||
|
k.removeFromList(m);
|
||||||
|
} else if(kostenBuch == 0){
|
||||||
|
bücherListe.add(b);
|
||||||
|
k.removeFromList(m);
|
||||||
|
BibliothekGUI.noMoneyOwed();
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case "DVD":
|
||||||
|
DVD d = (DVD) m;
|
||||||
|
double kostenDVD = berechneGebühren(d, kennnummer, rückgabeDatum);
|
||||||
|
String titelDVD = d.getTitel();
|
||||||
|
if(kostenDVD>0) {BibliothekGUI.zahlungsFenster2(kostenDVD, titelDVD, kennnummer, k);
|
||||||
|
k.addSchulden(kostenDVD);
|
||||||
|
dvdListe.add(d);
|
||||||
|
k.removeFromList(m);
|
||||||
|
} else {
|
||||||
|
dvdListe.add(d);
|
||||||
|
k.removeFromList(m);
|
||||||
|
BibliothekGUI.noMoneyOwed();
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case "CD":
|
||||||
|
CD c = (CD) m;
|
||||||
|
double kostenCD = berechneGebühren(c, kennnummer, rückgabeDatum);
|
||||||
|
String titelCD = c.getTitel();
|
||||||
|
if(kostenCD>0) {BibliothekGUI.zahlungsFenster2(kostenCD, titelCD, kennnummer, k);
|
||||||
|
k.addSchulden(kostenCD);
|
||||||
|
cdListe.add(c);
|
||||||
|
k.removeFromList(m);
|
||||||
|
} else {
|
||||||
|
cdListe.add(c);
|
||||||
|
k.removeFromList(m);
|
||||||
|
BibliothekGUI.noMoneyOwed();
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case "Brettspiel":
|
||||||
|
Brettspiel bs = (Brettspiel) m;
|
||||||
|
double kostenBS = berechneGebühren(bs, kennnummer, rückgabeDatum);
|
||||||
|
String titelBS = bs.getTitel();
|
||||||
|
if(kostenBS>0) {BibliothekGUI.zahlungsFenster2(kostenBS, titelBS, kennnummer, k);
|
||||||
|
k.addSchulden(kostenBS);
|
||||||
|
brettspielListe.add(bs);
|
||||||
|
k.removeFromList(m);
|
||||||
|
} else {
|
||||||
|
brettspielListe.add(bs);
|
||||||
|
k.removeFromList(m);
|
||||||
|
BibliothekGUI.noMoneyOwed();
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case "Videospiel":
|
||||||
|
Videospiel vs = (Videospiel) m;
|
||||||
|
double kostenVS = berechneGebühren(vs, kennnummer, rückgabeDatum);
|
||||||
|
String titelVS = vs.getTitel();
|
||||||
|
if(kostenVS>0) {BibliothekGUI.zahlungsFenster2(kostenVS, titelVS, kennnummer, k);
|
||||||
|
k.addSchulden(kostenVS);
|
||||||
|
videospielListe.add(vs);
|
||||||
|
k.removeFromList(m);
|
||||||
|
} else {
|
||||||
|
videospielListe.add(vs);
|
||||||
|
k.removeFromList(m);
|
||||||
|
BibliothekGUI.noMoneyOwed();
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static ArrayList<JLabel> findMatches(String searchTerm) {
|
||||||
|
ArrayList<JLabel> matches = new ArrayList<>();
|
||||||
|
for(Buch b: bücherListe) {
|
||||||
|
String titel = b.getTitel();
|
||||||
|
String autor = b.getAutor();
|
||||||
|
if(autor.contains(searchTerm) || titel.contains(searchTerm)) {
|
||||||
|
JLabel j = new JLabel("Buch namens: " + titel + " von " + b.getAutor());
|
||||||
|
matches.add(j);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for(CD c: cdListe) {
|
||||||
|
String titel = c.getTitel();
|
||||||
|
if(titel.contains(searchTerm)) {
|
||||||
|
JLabel j = new JLabel("CD namens: " + titel);
|
||||||
|
matches.add(j);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for(DVD d: dvdListe) {
|
||||||
|
String titel = d.getTitel();
|
||||||
|
if(titel.contains(searchTerm)) {
|
||||||
|
JLabel j = new JLabel("DVD namens: " + titel);
|
||||||
|
matches.add(j);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for(Brettspiel bp: brettspielListe) {
|
||||||
|
String titel = bp.getTitel();
|
||||||
|
if(titel.contains(searchTerm)) {
|
||||||
|
JLabel j = new JLabel("Brettspiel namens: " + titel);
|
||||||
|
matches.add(j);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for(Videospiel vs: videospielListe) {
|
||||||
|
String titel = vs.getTitel();
|
||||||
|
if(titel.contains(searchTerm)) {
|
||||||
|
JLabel j = new JLabel("Videospiel namens: " + titel);
|
||||||
|
matches.add(j);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return matches;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -18,19 +18,44 @@ public class BibliothekGUI extends JFrame implements ActionListener{
|
||||||
|
|
||||||
public BibliothekGUI() {
|
public BibliothekGUI() {
|
||||||
Bibliothek.makeEntries();
|
Bibliothek.makeEntries();
|
||||||
|
|
||||||
|
JPanel dateGrid = new JPanel(new GridLayout(1,4,10,10));
|
||||||
|
JLabel dateEntry = new JLabel("Datum eingeben: ");
|
||||||
|
String[] datumArray = {""};
|
||||||
|
JTextField dateInput = new JTextField(20);
|
||||||
|
JButton dateButton = new JButton("OK");
|
||||||
|
dateGrid.add(dateEntry);
|
||||||
|
dateGrid.add(dateInput);
|
||||||
|
dateGrid.add(dateButton);
|
||||||
JPanel loginPanel = new JPanel(new BorderLayout());
|
JPanel loginPanel = new JPanel(new BorderLayout());
|
||||||
JLabel text1 = new JLabel("Login mit Kennnummer:");
|
dateButton.addActionListener(e -> {
|
||||||
loginPanel.add(text1, BorderLayout.NORTH);
|
if(datumArray[0] != "") {
|
||||||
|
dateGrid.remove(dateGrid.getComponentCount() -1);
|
||||||
|
String newDate1 = dateInput.getText().toString();
|
||||||
|
datumArray[0] = newDate1;
|
||||||
|
JLabel dateState1 = new JLabel("Datum: " + datumArray[0]);
|
||||||
|
dateGrid.add(dateState1);
|
||||||
|
dateGrid.revalidate();
|
||||||
|
} else {
|
||||||
|
String newDate = dateInput.getText().toString();
|
||||||
|
datumArray[0] = newDate;
|
||||||
|
JLabel dateState = new JLabel("Datum: " + datumArray[0]);
|
||||||
|
dateGrid.add(dateState);
|
||||||
|
dateGrid.revalidate();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
loginPanel.add(dateGrid, BorderLayout.NORTH);
|
||||||
|
|
||||||
|
JLabel text1 = new JLabel("Login mit Kennnummer: ");
|
||||||
JPanel loginGrid = new JPanel(new BorderLayout());
|
JPanel loginGrid = new JPanel(new BorderLayout());
|
||||||
|
loginGrid.add(text1, BorderLayout.NORTH);
|
||||||
JTextField field1 = new JTextField(20);
|
JTextField field1 = new JTextField(20);
|
||||||
loginGrid.add(field1);
|
loginGrid.add(field1);
|
||||||
loginPanel.add(loginGrid, BorderLayout.CENTER);
|
loginPanel.add(loginGrid, BorderLayout.CENTER);
|
||||||
JButton b0 = new JButton("Registrieren");
|
JButton b0 = new JButton("Registrieren");
|
||||||
b0.addActionListener(e -> { nutzerAnlegen();});
|
b0.addActionListener(e -> { nutzerAnlegen();});
|
||||||
JButton b3 = new JButton("Ohne Anmeldung fortfahren");
|
JButton b3 = new JButton("Ohne Anmeldung fortfahren");
|
||||||
b3.addActionListener(e -> {
|
b3.addActionListener(e -> {browseMedia(datumArray[0]);});
|
||||||
browseMedia();
|
|
||||||
});
|
|
||||||
JPanel buttonGrid = new JPanel(new GridLayout(1,2,10,10));
|
JPanel buttonGrid = new JPanel(new GridLayout(1,2,10,10));
|
||||||
buttonGrid.add(b0);
|
buttonGrid.add(b0);
|
||||||
buttonGrid.add(b3);
|
buttonGrid.add(b3);
|
||||||
|
@ -47,7 +72,7 @@ public class BibliothekGUI extends JFrame implements ActionListener{
|
||||||
String text = k.getClass().toString();
|
String text = k.getClass().toString();
|
||||||
int lastDotIndex = text.lastIndexOf(".");
|
int lastDotIndex = text.lastIndexOf(".");
|
||||||
String substring = text.substring(lastDotIndex + 1);
|
String substring = text.substring(lastDotIndex + 1);
|
||||||
if(substring.equals("Kunde")) {openMainMenu(k);}
|
if(substring.equals("Kunde")) {openMainMenu(k, datumArray[0]);}
|
||||||
}});
|
}});
|
||||||
bp.add(b1);
|
bp.add(b1);
|
||||||
bp.add(b2);
|
bp.add(b2);
|
||||||
|
@ -60,8 +85,53 @@ public class BibliothekGUI extends JFrame implements ActionListener{
|
||||||
cl.show(mainPanel, "loginPanel");
|
cl.show(mainPanel, "loginPanel");
|
||||||
}
|
}
|
||||||
|
|
||||||
private void browseMedia() {
|
private static void openMainMenu(Kunde k, String datum) {
|
||||||
JPanel browsePanel = new JPanel(new GridLayout(6, 1, 10, 10));
|
JPanel mediumPanel = new JPanel(new GridLayout(7, 1, 10, 10));
|
||||||
|
|
||||||
|
JPanel dateGrid = new JPanel(new GridLayout(1,4,10,10));
|
||||||
|
JLabel dateEntry = new JLabel("Datum eingeben: ");
|
||||||
|
String[] datumArray = {datum};
|
||||||
|
JTextField dateInput = new JTextField(20);
|
||||||
|
JButton dateButton = new JButton("OK");
|
||||||
|
dateGrid.add(dateEntry);
|
||||||
|
dateGrid.add(dateInput);
|
||||||
|
dateGrid.add(dateButton);
|
||||||
|
JLabel dateState1 = new JLabel("Datum: " + datumArray[0]);
|
||||||
|
dateGrid.add(dateState1);
|
||||||
|
dateButton.addActionListener(e -> {
|
||||||
|
String newDate = dateInput.getText().toString();
|
||||||
|
datumArray[0] = newDate;
|
||||||
|
JLabel dateState = new JLabel("Datum: " + datumArray[0]);
|
||||||
|
dateGrid.remove(dateState1);
|
||||||
|
dateGrid.add(dateState);
|
||||||
|
dateGrid.revalidate();
|
||||||
|
});
|
||||||
|
mediumPanel.add(dateGrid, BorderLayout.NORTH);
|
||||||
|
|
||||||
|
JButton b0 = new JButton("Medien durchsuchen");
|
||||||
|
b0.addActionListener(e -> { medienDurchsuchenMenu(k);});
|
||||||
|
JButton b1 = new JButton("Ausleihe");
|
||||||
|
b1.addActionListener(e -> ausleihenMenü(k, datumArray[0]));
|
||||||
|
JButton b2 = new JButton("Rückgabe");
|
||||||
|
b2.addActionListener(e -> rückgabeMenü(k, datumArray[0]));
|
||||||
|
JButton b3 = new JButton("Meine Ausgeliehenen Medien");
|
||||||
|
b3.addActionListener(e -> myBooks(k));
|
||||||
|
JButton b4 = new JButton("Verlängern");
|
||||||
|
b4.addActionListener(e -> verlängern(k, datumArray[0]));
|
||||||
|
JButton b5= new JButton("Ausloggen");
|
||||||
|
b5.addActionListener(e -> cl.show(mainPanel, "loginPanel"));
|
||||||
|
mediumPanel.add(b0);
|
||||||
|
mediumPanel.add(b1);
|
||||||
|
mediumPanel.add(b2);
|
||||||
|
mediumPanel.add(b3);
|
||||||
|
mediumPanel.add(b4);
|
||||||
|
mediumPanel.add(b5);
|
||||||
|
mainPanel.add(mediumPanel, "mediumPanel");
|
||||||
|
cl.show(mainPanel, "mediumPanel");
|
||||||
|
}
|
||||||
|
|
||||||
|
private void browseMedia(String datum) {
|
||||||
|
JPanel browsePanel = new JPanel(new GridLayout(7, 1, 10, 10));
|
||||||
JButton b1 = new JButton("Bücher");
|
JButton b1 = new JButton("Bücher");
|
||||||
Kunde k = null;
|
Kunde k = null;
|
||||||
b1.addActionListener(e -> bookMenu(k));
|
b1.addActionListener(e -> bookMenu(k));
|
||||||
|
@ -73,18 +143,67 @@ public class BibliothekGUI extends JFrame implements ActionListener{
|
||||||
b4.addActionListener(e -> bsMenu(k));
|
b4.addActionListener(e -> bsMenu(k));
|
||||||
JButton b5 = new JButton("Videospiele");
|
JButton b5 = new JButton("Videospiele");
|
||||||
b5.addActionListener(e -> vsMenu(k));
|
b5.addActionListener(e -> vsMenu(k));
|
||||||
JButton b6 = new JButton("OK");
|
JButton b6 = new JButton("Rückgabe");
|
||||||
b6.addActionListener(e -> cl.show(mainPanel, "loginPanel"));
|
b6.addActionListener(e -> { rückgabeOhneUserID(datum);});
|
||||||
|
JButton b7 = new JButton("Zurück");
|
||||||
|
b7.addActionListener(e -> cl.show(mainPanel, "loginPanel"));
|
||||||
browsePanel.add(b1);
|
browsePanel.add(b1);
|
||||||
browsePanel.add(b2);
|
browsePanel.add(b2);
|
||||||
browsePanel.add(b3);
|
browsePanel.add(b3);
|
||||||
browsePanel.add(b4);
|
browsePanel.add(b4);
|
||||||
browsePanel.add(b5);
|
browsePanel.add(b5);
|
||||||
browsePanel.add(b6);
|
browsePanel.add(b6);
|
||||||
|
browsePanel.add(b7);
|
||||||
mainPanel.add(browsePanel, "browsePanel");
|
mainPanel.add(browsePanel, "browsePanel");
|
||||||
cl.show(mainPanel, "browsePanel");
|
cl.show(mainPanel, "browsePanel");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void rückgabeOhneUserID(String datum) {
|
||||||
|
JPanel rückgabeOhneIdMenü = new JPanel(new BorderLayout());
|
||||||
|
//NORTH
|
||||||
|
JPanel dateGrid = new JPanel(new GridLayout(1,4,10,10));
|
||||||
|
JLabel dateEntry = new JLabel("Datum eingeben: ");
|
||||||
|
String[] datumArray = {datum};
|
||||||
|
JTextField dateInput = new JTextField(20);
|
||||||
|
JButton dateButton = new JButton("OK");
|
||||||
|
dateGrid.add(dateEntry);
|
||||||
|
dateGrid.add(dateInput);
|
||||||
|
dateGrid.add(dateButton);
|
||||||
|
JLabel dateState1 = new JLabel("Datum: " + datumArray[0]);
|
||||||
|
dateGrid.add(dateState1);
|
||||||
|
dateButton.addActionListener(e -> {
|
||||||
|
String newDate = dateInput.getText().toString();
|
||||||
|
datumArray[0] = newDate;
|
||||||
|
JLabel dateState = new JLabel("Datum: " + datumArray[0]);
|
||||||
|
dateGrid.remove(dateState1);
|
||||||
|
dateGrid.add(dateState);
|
||||||
|
dateGrid.revalidate();
|
||||||
|
});
|
||||||
|
rückgabeOhneIdMenü.add(dateGrid, BorderLayout.NORTH);
|
||||||
|
//CENTER
|
||||||
|
JPanel inputMenu = new JPanel(new GridLayout(2, 1, 10, 10));
|
||||||
|
JLabel text1 = new JLabel("Zu ausleihende Kennnummer des Mediums eingeben:");
|
||||||
|
JTextField inputField1 = new JTextField(20);
|
||||||
|
inputMenu.add(text1);
|
||||||
|
inputMenu.add(inputField1);
|
||||||
|
rückgabeOhneIdMenü.add(inputMenu, BorderLayout.CENTER);
|
||||||
|
//SOUTH
|
||||||
|
JPanel buttonGrid = new JPanel(new GridLayout(1, 2, 10,10));
|
||||||
|
JButton b1 = new JButton("Abbrechen");
|
||||||
|
b1.addActionListener(e -> cl.show(mainPanel, "mediumPanel"));
|
||||||
|
JButton b2 = new JButton("OK");
|
||||||
|
buttonGrid.add(b1);
|
||||||
|
buttonGrid.add(b2);
|
||||||
|
rückgabeOhneIdMenü.add(buttonGrid, BorderLayout.SOUTH);
|
||||||
|
b2.addActionListener(e -> {
|
||||||
|
int kennnummer = Integer.parseInt(inputField1.getText());
|
||||||
|
Kunde k = Bibliothek.findKunde(kennnummer);
|
||||||
|
Bibliothek.rückgabe2(kennnummer, datumArray[0], k);
|
||||||
|
});
|
||||||
|
mainPanel.add(rückgabeOhneIdMenü, "Rückgabe1");
|
||||||
|
cl.show(mainPanel, "Rückgabe1");
|
||||||
|
}
|
||||||
|
|
||||||
private void nutzerAnlegen() {
|
private void nutzerAnlegen() {
|
||||||
JPanel registerMenu = new JPanel(new BorderLayout());
|
JPanel registerMenu = new JPanel(new BorderLayout());
|
||||||
int newKennnummer = Bibliothek.getNewKennnummer();
|
int newKennnummer = Bibliothek.getNewKennnummer();
|
||||||
|
@ -195,10 +314,10 @@ public class BibliothekGUI extends JFrame implements ActionListener{
|
||||||
cl.show(mainPanel, "changeOwed");
|
cl.show(mainPanel, "changeOwed");
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void openMainMenu(Kunde k) {
|
private static void medienDurchsuchenMenu(Kunde k) {
|
||||||
JPanel mediumPanel = new JPanel(new GridLayout(12, 1, 10, 10));
|
JPanel suchenPanel = new JPanel(new GridLayout(7,1,10,10));
|
||||||
JLabel text1 = new JLabel("Ihre Kennnnummer: " + k.getKennnummer());
|
JButton b0 = new JButton("Stichwortsuche");
|
||||||
mediumPanel.add(text1);
|
b0.addActionListener(e -> searchMenu(k));
|
||||||
JButton b1 = new JButton("Bücher");
|
JButton b1 = new JButton("Bücher");
|
||||||
b1.addActionListener(e -> bookMenu(k));
|
b1.addActionListener(e -> bookMenu(k));
|
||||||
JButton b2 = new JButton("DVDs");
|
JButton b2 = new JButton("DVDs");
|
||||||
|
@ -209,34 +328,59 @@ public class BibliothekGUI extends JFrame implements ActionListener{
|
||||||
b4.addActionListener(e -> bsMenu(k));
|
b4.addActionListener(e -> bsMenu(k));
|
||||||
JButton b5 = new JButton("Videospiele");
|
JButton b5 = new JButton("Videospiele");
|
||||||
b5.addActionListener(e -> vsMenu(k));
|
b5.addActionListener(e -> vsMenu(k));
|
||||||
JButton b6 = new JButton("Ausleihe");
|
JButton b6 = new JButton("Zurück");
|
||||||
b6.addActionListener(e -> ausleihenMenü(k));
|
b6.addActionListener(e -> cl.show(mainPanel, "mediumPanel"));
|
||||||
JButton b7 = new JButton("Rückgabe");
|
suchenPanel.add(b0);
|
||||||
b7.addActionListener(e -> rückgabeMenü(k));
|
suchenPanel.add(b1);
|
||||||
JButton b8 = new JButton("Meine Ausgeliehenen Medien");
|
suchenPanel.add(b2);
|
||||||
b8.addActionListener(e -> myBooks(k));
|
suchenPanel.add(b3);
|
||||||
JButton b9 = new JButton("Verlängern");
|
suchenPanel.add(b4);
|
||||||
b9.addActionListener(e -> verlängern(k));
|
suchenPanel.add(b5);
|
||||||
JButton b10 = new JButton("Meine Schulden abbezahlen");
|
suchenPanel.add(b6);
|
||||||
b10.addActionListener(e -> schuldenBegleichen(k));
|
mainPanel.add(suchenPanel, "suchenMenu");
|
||||||
JButton b11 = new JButton("Ausloggen");
|
cl.show(mainPanel, "suchenMenu");
|
||||||
b11.addActionListener(e -> cl.show(mainPanel, "loginPanel"));
|
|
||||||
mediumPanel.add(b1);
|
|
||||||
mediumPanel.add(b2);
|
|
||||||
mediumPanel.add(b3);
|
|
||||||
mediumPanel.add(b4);
|
|
||||||
mediumPanel.add(b5);
|
|
||||||
mediumPanel.add(b6);
|
|
||||||
mediumPanel.add(b7);
|
|
||||||
mediumPanel.add(b8);
|
|
||||||
mediumPanel.add(b9);
|
|
||||||
mediumPanel.add(b10);
|
|
||||||
mediumPanel.add(b11);
|
|
||||||
mainPanel.add(mediumPanel, "mediumPanel");
|
|
||||||
cl.show(mainPanel, "mediumPanel");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void verlängern(Kunde k) {
|
private static void searchMenu(Kunde k) {
|
||||||
|
JPanel mainSearch = new JPanel(new BorderLayout());
|
||||||
|
//NORTH: Search bar
|
||||||
|
JPanel enterSearch = new JPanel(new GridLayout(1,3,10,10));
|
||||||
|
JLabel text0 = new JLabel("Geben Sie einen Suchbegriff ein:");
|
||||||
|
JTextField enterSearchTerm = new JTextField(20);
|
||||||
|
JButton b0 = new JButton("Suchen");
|
||||||
|
enterSearch.add(text0);
|
||||||
|
enterSearch.add(enterSearchTerm);
|
||||||
|
enterSearch.add(b0);
|
||||||
|
mainSearch.add(enterSearch, BorderLayout.NORTH);
|
||||||
|
//CENTER: Matched media
|
||||||
|
b0.addActionListener(e -> {
|
||||||
|
String searchTerm = enterSearchTerm.getText().toString();
|
||||||
|
ArrayList<JLabel> matchedMedia = Bibliothek.findMatches(searchTerm);
|
||||||
|
int i = matchedMedia.size();
|
||||||
|
if(i == 0) {
|
||||||
|
JLabel text1 = new JLabel("Nichts passendes zu dem Suchbegriff " + searchTerm + " gefunden.");
|
||||||
|
mainSearch.add(text0, BorderLayout.CENTER);
|
||||||
|
} else if (i > 0){
|
||||||
|
JPanel ergebnisPanel = new JPanel(new GridLayout(i, 1, 10,10));
|
||||||
|
for(JLabel j: matchedMedia) {
|
||||||
|
ergebnisPanel.add(j);
|
||||||
|
}
|
||||||
|
mainSearch.revalidate();
|
||||||
|
mainSearch.add(ergebnisPanel, BorderLayout.CENTER);
|
||||||
|
mainSearch.revalidate();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
//SOUTH: OK Button to return
|
||||||
|
JButton b1 = new JButton("OK");
|
||||||
|
b1.addActionListener(e -> cl.show(mainPanel, "suchenMenu"));
|
||||||
|
mainSearch.add(b1, BorderLayout.SOUTH);
|
||||||
|
|
||||||
|
mainPanel.add(mainSearch, "Stichwort");
|
||||||
|
cl.show(mainPanel, "Stichwort");
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void verlängern(Kunde k, String datumArray) {
|
||||||
|
|
||||||
JPanel verlängerungPanel = new JPanel(new BorderLayout());
|
JPanel verlängerungPanel = new JPanel(new BorderLayout());
|
||||||
JLabel text0 = new JLabel("Geben Sie die Kennnumer des Mediums ein, dessen Rückgabezeit sie verlängern möchten.");
|
JLabel text0 = new JLabel("Geben Sie die Kennnumer des Mediums ein, dessen Rückgabezeit sie verlängern möchten.");
|
||||||
JTextField inputField = new JTextField(20);
|
JTextField inputField = new JTextField(20);
|
||||||
|
@ -313,95 +457,95 @@ public class BibliothekGUI extends JFrame implements ActionListener{
|
||||||
cl.show(mainPanel, "Verlängerung2");
|
cl.show(mainPanel, "Verlängerung2");
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void schuldenBegleichen(Kunde k) {
|
|
||||||
JPanel schuldenMenü = new JPanel(new BorderLayout());
|
|
||||||
double schulden = k.getSchulden();
|
|
||||||
if(schulden > 0) {
|
|
||||||
JLabel text0 = new JLabel("Sie haben " + schulden + "€ Schulden. Geben Sie unten ein, wie viel Sie zahlen möchten.");
|
|
||||||
JTextField inputField1 = new JTextField(20);
|
|
||||||
JButton b1 = new JButton("OK");
|
|
||||||
schuldenMenü.add(text0, BorderLayout.NORTH);
|
|
||||||
schuldenMenü.add(inputField1, BorderLayout.CENTER);
|
|
||||||
JPanel buttonGrid = new JPanel(new GridLayout(1,2,10,10));
|
|
||||||
JButton b2 = new JButton("Abbrechen");
|
|
||||||
b2.addActionListener(e -> cl.show(mainPanel, "mediumPanel"));
|
|
||||||
buttonGrid.add(b2);
|
|
||||||
buttonGrid.add(b1);
|
|
||||||
schuldenMenü.add(buttonGrid, BorderLayout.SOUTH);
|
|
||||||
b1.addActionListener(e -> {
|
|
||||||
int einzahlung = Integer.parseInt(inputField1.getText());
|
|
||||||
double newSchulden = schulden - einzahlung;
|
|
||||||
k.setSchulden(newSchulden);
|
|
||||||
cl.show(mainPanel, "mediumPanel");
|
|
||||||
});
|
|
||||||
} else if(schulden <= 0){
|
|
||||||
JLabel text0 = new JLabel("Sie haben keine Schulden.");
|
|
||||||
JLabel text1 = new JLabel("Ihr Guthaben beträgt " + schulden*(-1) + "€.");
|
|
||||||
JButton b1 = new JButton("OK");
|
|
||||||
schuldenMenü.add(text0, BorderLayout.NORTH);
|
|
||||||
schuldenMenü.add(text1, BorderLayout.CENTER);
|
|
||||||
schuldenMenü.add(b1, BorderLayout.SOUTH);
|
|
||||||
b1.addActionListener(e -> {
|
|
||||||
cl.show(mainPanel, "mediumPanel");
|
|
||||||
});
|
|
||||||
}
|
|
||||||
mainPanel.add(schuldenMenü, "Schulden");
|
|
||||||
cl.show(mainPanel, "Schulden");
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void ausleihenMenü(Kunde k) {
|
|
||||||
|
private static void ausleihenMenü(Kunde k, String datum) {
|
||||||
JPanel ausleihMenü = new JPanel(new BorderLayout());
|
JPanel ausleihMenü = new JPanel(new BorderLayout());
|
||||||
JPanel inputMenu = new JPanel(new GridLayout(4, 1, 10, 10));
|
//NORTH
|
||||||
|
JPanel dateGrid = new JPanel(new GridLayout(1,4,10,10));
|
||||||
|
JLabel dateEntry = new JLabel("Datum eingeben: ");
|
||||||
|
String[] datumArray = {datum};
|
||||||
|
JTextField dateInput = new JTextField(20);
|
||||||
|
JButton dateButton = new JButton("OK");
|
||||||
|
dateGrid.add(dateEntry);
|
||||||
|
dateGrid.add(dateInput);
|
||||||
|
dateGrid.add(dateButton);
|
||||||
|
JLabel dateState1 = new JLabel("Datum: " + datumArray[0]);
|
||||||
|
dateGrid.add(dateState1);
|
||||||
|
dateButton.addActionListener(e -> {
|
||||||
|
String newDate = dateInput.getText().toString();
|
||||||
|
datumArray[0] = newDate;
|
||||||
|
JLabel dateState = new JLabel("Datum: " + datumArray[0]);
|
||||||
|
dateGrid.remove(dateState1);
|
||||||
|
dateGrid.add(dateState);
|
||||||
|
dateGrid.revalidate();
|
||||||
|
});
|
||||||
|
ausleihMenü.add(dateGrid, BorderLayout.NORTH);
|
||||||
|
//CENTER
|
||||||
|
JPanel inputMenu = new JPanel(new GridLayout(2, 1, 10, 10));
|
||||||
JLabel text1 = new JLabel("Zu ausleihende Kennnummer des Mediums eingeben:");
|
JLabel text1 = new JLabel("Zu ausleihende Kennnummer des Mediums eingeben:");
|
||||||
JTextField inputField1 = new JTextField(20);
|
JTextField inputField1 = new JTextField(20);
|
||||||
JLabel text2 = new JLabel("Datum eingeben:");
|
|
||||||
JTextField inputField2 = new JTextField(20);
|
|
||||||
inputMenu.add(text1);
|
inputMenu.add(text1);
|
||||||
inputMenu.add(inputField1);
|
inputMenu.add(inputField1);
|
||||||
inputMenu.add(text2);
|
|
||||||
inputMenu.add(inputField2);
|
|
||||||
ausleihMenü.add(inputMenu, BorderLayout.CENTER);
|
ausleihMenü.add(inputMenu, BorderLayout.CENTER);
|
||||||
|
//SOUTH
|
||||||
JPanel buttonGrid = new JPanel(new GridLayout(1, 2, 10,10));
|
JPanel buttonGrid = new JPanel(new GridLayout(1, 2, 10,10));
|
||||||
JButton b1 = new JButton("Abbrechen");
|
JButton b1 = new JButton("Abbrechen");
|
||||||
b1.addActionListener(e -> cl.show(mainPanel, "mediumPanel"));
|
b1.addActionListener(e -> cl.show(mainPanel, "mediumPanel"));
|
||||||
JButton b2 = new JButton("OK");
|
JButton b2 = new JButton("OK");
|
||||||
b2.addActionListener(e -> {
|
|
||||||
int kennnummer = Integer.parseInt(inputField1.getText());
|
|
||||||
String ausleihDatum = inputField2.getText().toString();
|
|
||||||
Bibliothek.ausleihe(kennnummer, ausleihDatum, k);
|
|
||||||
cl.show(mainPanel, "mediumPanel");
|
|
||||||
});
|
|
||||||
buttonGrid.add(b1);
|
buttonGrid.add(b1);
|
||||||
buttonGrid.add(b2);
|
buttonGrid.add(b2);
|
||||||
ausleihMenü.add(buttonGrid, BorderLayout.SOUTH);
|
ausleihMenü.add(buttonGrid, BorderLayout.SOUTH);
|
||||||
|
b2.addActionListener(e -> {
|
||||||
|
int kennnummer = Integer.parseInt(inputField1.getText());
|
||||||
|
Bibliothek.ausleihe(kennnummer, datumArray[0], k);
|
||||||
|
cl.show(mainPanel, "mediumPanel");
|
||||||
|
});
|
||||||
mainPanel.add(ausleihMenü, "Ausleihen");
|
mainPanel.add(ausleihMenü, "Ausleihen");
|
||||||
cl.show(mainPanel, "Ausleihen");
|
cl.show(mainPanel, "Ausleihen");
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void rückgabeMenü(Kunde k) {
|
private static void rückgabeMenü(Kunde k, String datum) {
|
||||||
JPanel rückgabeMenü = new JPanel(new BorderLayout());
|
JPanel rückgabeMenü = new JPanel(new BorderLayout());
|
||||||
JPanel inputMenu = new JPanel(new GridLayout(4,1,10,10));
|
//NORTH
|
||||||
JLabel text1 = new JLabel("Kennnummer des Mediums zur Rückgabe eingeben:");
|
JPanel dateGrid = new JPanel(new GridLayout(1,4,10,10));
|
||||||
|
JLabel dateEntry = new JLabel("Datum eingeben: ");
|
||||||
|
String[] datumArray = {datum};
|
||||||
|
JTextField dateInput = new JTextField(20);
|
||||||
|
JButton dateButton = new JButton("OK");
|
||||||
|
dateGrid.add(dateEntry);
|
||||||
|
dateGrid.add(dateInput);
|
||||||
|
dateGrid.add(dateButton);
|
||||||
|
JLabel dateState1 = new JLabel("Datum: " + datumArray[0]);
|
||||||
|
dateGrid.add(dateState1);
|
||||||
|
dateButton.addActionListener(e -> {
|
||||||
|
String newDate = dateInput.getText().toString();
|
||||||
|
datumArray[0] = newDate;
|
||||||
|
JLabel dateState = new JLabel("Datum: " + datumArray[0]);
|
||||||
|
dateGrid.remove(dateState1);
|
||||||
|
dateGrid.add(dateState);
|
||||||
|
dateGrid.revalidate();
|
||||||
|
});
|
||||||
|
rückgabeMenü.add(dateGrid, BorderLayout.NORTH);
|
||||||
|
//CENTER
|
||||||
|
JPanel inputMenu = new JPanel(new GridLayout(2, 1, 10, 10));
|
||||||
|
JLabel text1 = new JLabel("Zu ausleihende Kennnummer des Mediums eingeben:");
|
||||||
JTextField inputField1 = new JTextField(20);
|
JTextField inputField1 = new JTextField(20);
|
||||||
JLabel text2 = new JLabel("Datum eingeben:");
|
|
||||||
JTextField inputField2 = new JTextField(20);
|
|
||||||
inputMenu.add(text1);
|
inputMenu.add(text1);
|
||||||
inputMenu.add(inputField1);
|
inputMenu.add(inputField1);
|
||||||
inputMenu.add(text2);
|
rückgabeMenü.add(inputMenu, BorderLayout.CENTER);
|
||||||
inputMenu.add(inputField2);
|
//SOUTH
|
||||||
rückgabeMenü.add(inputMenu, BorderLayout.CENTER);;
|
|
||||||
JPanel buttonGrid = new JPanel(new GridLayout(1, 2, 10,10));
|
JPanel buttonGrid = new JPanel(new GridLayout(1, 2, 10,10));
|
||||||
JButton b1 = new JButton("Abbrechen");
|
JButton b1 = new JButton("Abbrechen");
|
||||||
b1.addActionListener(e -> cl.show(mainPanel, "mediumPanel"));
|
b1.addActionListener(e -> cl.show(mainPanel, "mediumPanel"));
|
||||||
JButton b2 = new JButton("OK");
|
JButton b2 = new JButton("OK");
|
||||||
b2.addActionListener(e -> {
|
|
||||||
int kennnummer = Integer.parseInt(inputField1.getText());
|
|
||||||
String rückgabeDatum = inputField2.getText().toString();
|
|
||||||
Bibliothek.rückgabe(kennnummer, rückgabeDatum, k);
|
|
||||||
});
|
|
||||||
buttonGrid.add(b1);
|
buttonGrid.add(b1);
|
||||||
buttonGrid.add(b2);
|
buttonGrid.add(b2);
|
||||||
rückgabeMenü.add(buttonGrid, BorderLayout.SOUTH);
|
rückgabeMenü.add(buttonGrid, BorderLayout.SOUTH);
|
||||||
|
b2.addActionListener(e -> {
|
||||||
|
int kennnummer = Integer.parseInt(inputField1.getText());
|
||||||
|
Bibliothek.rückgabe(kennnummer, datumArray[0], k);
|
||||||
|
});
|
||||||
mainPanel.add(rückgabeMenü, "Rückgabe");
|
mainPanel.add(rückgabeMenü, "Rückgabe");
|
||||||
cl.show(mainPanel, "Rückgabe");
|
cl.show(mainPanel, "Rückgabe");
|
||||||
}
|
}
|
||||||
|
@ -420,7 +564,7 @@ public class BibliothekGUI extends JFrame implements ActionListener{
|
||||||
if(k == null) {
|
if(k == null) {
|
||||||
cl.show(mainPanel, "browsePanel");
|
cl.show(mainPanel, "browsePanel");
|
||||||
} else {
|
} else {
|
||||||
cl.show(mainPanel, "mediumPanel");}
|
cl.show(mainPanel, "suchenMenu");}
|
||||||
});
|
});
|
||||||
buchMenü.add(b1, BorderLayout.SOUTH);
|
buchMenü.add(b1, BorderLayout.SOUTH);
|
||||||
mainPanel.add(buchMenü, "Bücher");
|
mainPanel.add(buchMenü, "Bücher");
|
||||||
|
@ -441,7 +585,7 @@ public class BibliothekGUI extends JFrame implements ActionListener{
|
||||||
if(k == null) {
|
if(k == null) {
|
||||||
cl.show(mainPanel, "browsePanel");
|
cl.show(mainPanel, "browsePanel");
|
||||||
} else {
|
} else {
|
||||||
cl.show(mainPanel, "mediumPanel");}
|
cl.show(mainPanel, "suchenMenu");}
|
||||||
});
|
});
|
||||||
dvdMenü.add(b1, BorderLayout.SOUTH);
|
dvdMenü.add(b1, BorderLayout.SOUTH);
|
||||||
mainPanel.add(dvdMenü, "DVDs");
|
mainPanel.add(dvdMenü, "DVDs");
|
||||||
|
@ -462,7 +606,7 @@ public class BibliothekGUI extends JFrame implements ActionListener{
|
||||||
if(k == null) {
|
if(k == null) {
|
||||||
cl.show(mainPanel, "browsePanel");
|
cl.show(mainPanel, "browsePanel");
|
||||||
} else {
|
} else {
|
||||||
cl.show(mainPanel, "mediumPanel");}
|
cl.show(mainPanel, "suchenMenu");}
|
||||||
}); cdMenü.add(b1, BorderLayout.SOUTH);
|
}); cdMenü.add(b1, BorderLayout.SOUTH);
|
||||||
mainPanel.add(cdMenü, "CDs");
|
mainPanel.add(cdMenü, "CDs");
|
||||||
cl.show(mainPanel, "CDs");
|
cl.show(mainPanel, "CDs");
|
||||||
|
@ -482,7 +626,7 @@ public class BibliothekGUI extends JFrame implements ActionListener{
|
||||||
if(k == null) {
|
if(k == null) {
|
||||||
cl.show(mainPanel, "browsePanel");
|
cl.show(mainPanel, "browsePanel");
|
||||||
} else {
|
} else {
|
||||||
cl.show(mainPanel, "mediumPanel");}
|
cl.show(mainPanel, "suchenMenu");}
|
||||||
}); bsMenü.add(b1, BorderLayout.SOUTH);
|
}); bsMenü.add(b1, BorderLayout.SOUTH);
|
||||||
mainPanel.add(bsMenü, "Brettspiele");
|
mainPanel.add(bsMenü, "Brettspiele");
|
||||||
cl.show(mainPanel, "Brettspiele");
|
cl.show(mainPanel, "Brettspiele");
|
||||||
|
@ -502,7 +646,7 @@ public class BibliothekGUI extends JFrame implements ActionListener{
|
||||||
if(k == null) {
|
if(k == null) {
|
||||||
cl.show(mainPanel, "browsePanel");
|
cl.show(mainPanel, "browsePanel");
|
||||||
} else {
|
} else {
|
||||||
cl.show(mainPanel, "mediumPanel");}
|
cl.show(mainPanel, "suchenMenu");}
|
||||||
}); vsMenü.add(b1, BorderLayout.SOUTH);
|
}); vsMenü.add(b1, BorderLayout.SOUTH);
|
||||||
mainPanel.add(vsMenü, "Videospiele");
|
mainPanel.add(vsMenü, "Videospiele");
|
||||||
cl.show(mainPanel, "Videospiele");
|
cl.show(mainPanel, "Videospiele");
|
||||||
|
@ -532,52 +676,37 @@ public class BibliothekGUI extends JFrame implements ActionListener{
|
||||||
|
|
||||||
public static void zahlungsFenster(double kosten, String titel, int kennnummer, Kunde k) {
|
public static void zahlungsFenster(double kosten, String titel, int kennnummer, Kunde k) {
|
||||||
JPanel zahlungPanel = new JPanel(new BorderLayout());
|
JPanel zahlungPanel = new JPanel(new BorderLayout());
|
||||||
JLabel text1 = new JLabel("Sie schulden für das Buch " + titel + " mit der Kennnummer " + kennnummer + " " + kosten + "€.");
|
//CENTER
|
||||||
zahlungPanel.add(text1, BorderLayout.NORTH);
|
JLabel text1 = new JLabel("Sie schulden für das Buch " + titel + " mit der Kennnummer " + kennnummer + " " + kosten + "€. Bitte zahlen Sie die Gebühren an der Kasse.");
|
||||||
JPanel zahlungPanelMitte = new JPanel(new GridLayout(2,1,10,10));
|
zahlungPanel.add(text1, BorderLayout.CENTER);
|
||||||
JLabel text3 = new JLabel("Geben Sie ein wieviel sie zahlen:");
|
//SOUTH
|
||||||
zahlungPanelMitte.add(text3);
|
|
||||||
JTextField inputField1 = new JTextField(20);
|
|
||||||
zahlungPanelMitte.add(inputField1);
|
|
||||||
zahlungPanel.add(zahlungPanelMitte, BorderLayout.CENTER);
|
|
||||||
JButton b1 = new JButton("OK");
|
JButton b1 = new JButton("OK");
|
||||||
zahlungPanel.add(b1, BorderLayout.SOUTH);
|
zahlungPanel.add(b1, BorderLayout.SOUTH);
|
||||||
mainPanel.add(zahlungPanel,"Zahlung1");
|
|
||||||
cl.show(mainPanel, "Zahlung1");
|
|
||||||
b1.addActionListener(e -> {
|
b1.addActionListener(e -> {
|
||||||
String paymentString = inputField1.getText().toString();
|
myBooks(k);
|
||||||
zahlungStatus(paymentString, kosten, k);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void zahlungStatus(String zahlungStr, double kosten, Kunde k) {
|
|
||||||
int zahlung = Integer.parseInt(zahlungStr);
|
|
||||||
boolean zahlungErfolgreich = Bibliothek.zahlungRegistrieren(zahlung, kosten);
|
|
||||||
JPanel zahlungStatusPanel = new JPanel(new BorderLayout());
|
|
||||||
JLabel text2 = new JLabel("Zahlungsstatus:");
|
|
||||||
zahlungStatusPanel.add(text2, BorderLayout.NORTH);
|
|
||||||
JButton b2 = new JButton("OK");
|
|
||||||
zahlungStatusPanel.add(b2, BorderLayout.SOUTH);
|
|
||||||
if(zahlungErfolgreich == true) {
|
|
||||||
JLabel text4 = new JLabel("Zahlung war erfolgreich!");
|
|
||||||
zahlungStatusPanel.add(text4, BorderLayout.CENTER);
|
|
||||||
k.setSchulden(kosten - zahlung);
|
|
||||||
} else {
|
|
||||||
k.setSchulden(kosten - zahlung);
|
|
||||||
double schulden = k.getSchulden();
|
|
||||||
JLabel text4 = new JLabel("Zahlung fehlgeschlagen! Ihnen wurden " + schulden + "€ Schulden zugeschrieben.");
|
|
||||||
zahlungStatusPanel.add(text4, BorderLayout.CENTER);
|
|
||||||
}
|
|
||||||
mainPanel.add(zahlungStatusPanel, "Zahlung2");
|
|
||||||
cl.show(mainPanel, "Zahlung2");
|
|
||||||
b2.addActionListener(e -> {
|
|
||||||
cl.show(mainPanel, "mediumPanel");
|
|
||||||
});
|
});
|
||||||
|
mainPanel.add(zahlungPanel,"Zahlung");
|
||||||
|
cl.show(mainPanel, "Zahlung");
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void noMoneyOwed() {
|
public static void noMoneyOwed() {
|
||||||
cl.show(mainPanel, "mediumPanel");
|
cl.show(mainPanel, "mediumPanel");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void zahlungsFenster2(double kosten, String titel, int kennnummer, Kunde k) {
|
||||||
|
JPanel zahlungPanel = new JPanel(new BorderLayout());
|
||||||
|
//CENTER
|
||||||
|
JLabel text1 = new JLabel("Sie schulden für das Buch " + titel + " mit der Kennnummer " + kennnummer + " " + kosten + "€. Bitte zahlen Sie die Gebühren an der Kasse.");
|
||||||
|
zahlungPanel.add(text1, BorderLayout.CENTER);
|
||||||
|
//SOUTH
|
||||||
|
JButton b1 = new JButton("OK");
|
||||||
|
zahlungPanel.add(b1, BorderLayout.SOUTH);
|
||||||
|
b1.addActionListener(e -> {
|
||||||
|
cl.show(mainPanel, "browsePanel");
|
||||||
|
});
|
||||||
|
mainPanel.add(zahlungPanel,"Zahlung2");
|
||||||
|
cl.show(mainPanel, "Zahlung2");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
Loading…
Reference in New Issue