changed how program handles dates and added search tab
parent
8b1904c138
commit
462242c4e4
|
@ -22,4 +22,4 @@ class Mitarbeiter extends Benutzer {
|
|||
public boolean istStudent() {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -80,6 +80,11 @@ public class Bibliothek {
|
|||
Kunde k3 = new Kunde(false, 3);
|
||||
Kunde k4 = new Kunde(false, 4);
|
||||
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(k2);
|
||||
kundenListe.add(k3);
|
||||
|
@ -87,7 +92,7 @@ public class Bibliothek {
|
|||
kundenListe.add(k5);
|
||||
|
||||
for(Buch b: bücherListe) {
|
||||
katalog.add(b);
|
||||
katalog.add(b);
|
||||
}
|
||||
for(DVD d: dvdListe) {
|
||||
katalog.add(d);
|
||||
|
@ -100,7 +105,7 @@ public class Bibliothek {
|
|||
}
|
||||
for(Videospiel vs: videospielListe) {
|
||||
katalog.add(vs);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static Kunde validateLogin(int login) {
|
||||
|
@ -279,22 +284,25 @@ public class Bibliothek {
|
|||
Buch b = (Buch) m;
|
||||
double kostenBuch = berechneGebühren(b, kennnummer, rückgabeDatum);
|
||||
String titelBuch = b.getTitel();
|
||||
if(kostenBuch>0) {BibliothekGUI.zahlungsFenster(kostenBuch, titelBuch, kennnummer, k);
|
||||
bücherListe.add(b);
|
||||
k.removeFromList(m);
|
||||
} else {
|
||||
bücherListe.add(b);
|
||||
k.removeFromList(m);
|
||||
BibliothekGUI.noMoneyOwed();
|
||||
if(kostenBuch > 0) {
|
||||
k.removeFromList(m);
|
||||
BibliothekGUI.zahlungsFenster(kostenBuch, titelBuch, kennnummer, k);
|
||||
k.addSchulden(kostenBuch);
|
||||
bücherListe.add(b);
|
||||
} 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.zahlungsFenster(kostenDVD, titelDVD, kennnummer, k);
|
||||
dvdListe.add(d);
|
||||
k.removeFromList(m);
|
||||
if(kostenDVD>0) {BibliothekGUI.zahlungsFenster(kostenDVD, titelDVD, kennnummer, k);
|
||||
k.addSchulden(kostenDVD);
|
||||
dvdListe.add(d);
|
||||
} else {
|
||||
dvdListe.add(d);
|
||||
k.removeFromList(m);
|
||||
|
@ -305,9 +313,10 @@ public class Bibliothek {
|
|||
CD c = (CD) m;
|
||||
double kostenCD = berechneGebühren(c, kennnummer, rückgabeDatum);
|
||||
String titelCD = c.getTitel();
|
||||
if(kostenCD>0) {BibliothekGUI.zahlungsFenster(kostenCD, titelCD, kennnummer, k);
|
||||
cdListe.add(c);
|
||||
k.removeFromList(m);
|
||||
if(kostenCD>0) {BibliothekGUI.zahlungsFenster(kostenCD, titelCD, kennnummer, k);
|
||||
k.addSchulden(kostenCD);
|
||||
cdListe.add(c);
|
||||
} else {
|
||||
cdListe.add(c);
|
||||
k.removeFromList(m);
|
||||
|
@ -318,9 +327,10 @@ public class Bibliothek {
|
|||
Brettspiel bs = (Brettspiel) m;
|
||||
double kostenBS = berechneGebühren(bs, kennnummer, rückgabeDatum);
|
||||
String titelBS = bs.getTitel();
|
||||
if(kostenBS>0) {BibliothekGUI.zahlungsFenster(kostenBS, titelBS, kennnummer, k);
|
||||
brettspielListe.add(bs);
|
||||
k.removeFromList(m);
|
||||
if(kostenBS>0) {BibliothekGUI.zahlungsFenster(kostenBS, titelBS, kennnummer, k);
|
||||
k.addSchulden(kostenBS);
|
||||
brettspielListe.add(bs);
|
||||
} else {
|
||||
brettspielListe.add(bs);
|
||||
k.removeFromList(m);
|
||||
|
@ -331,9 +341,10 @@ public class Bibliothek {
|
|||
Videospiel vs = (Videospiel) m;
|
||||
double kostenVS = berechneGebühren(vs, kennnummer, rückgabeDatum);
|
||||
String titelVS = vs.getTitel();
|
||||
if(kostenVS>0) {BibliothekGUI.zahlungsFenster(kostenVS, titelVS, kennnummer, k);
|
||||
videospielListe.add(vs);
|
||||
k.removeFromList(m);
|
||||
if(kostenVS>0) {BibliothekGUI.zahlungsFenster(kostenVS, titelVS, kennnummer, k);
|
||||
k.addSchulden(kostenVS);
|
||||
videospielListe.add(vs);
|
||||
} else {
|
||||
videospielListe.add(vs);
|
||||
k.removeFromList(m);
|
||||
|
@ -535,6 +546,7 @@ public class Bibliothek {
|
|||
ArrayList<Medium> ausgeliehenListe = k.returnAusgelieheneMedien();
|
||||
for(Medium m: ausgeliehenListe) {
|
||||
if(m.getKennnummer() == kennnummer) {
|
||||
|
||||
if(m.getVerlängerungen() > 0) {
|
||||
m.setVerlängerung();
|
||||
datumVerlängern(m, k);
|
||||
|
@ -567,7 +579,145 @@ 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;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -49,4 +49,4 @@ public class Kunde extends Benutzer {
|
|||
public void removeFromList(Medium m) {
|
||||
ausgelieheneMedien.remove(m);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -18,19 +18,44 @@ public class BibliothekGUI extends JFrame implements ActionListener{
|
|||
|
||||
public BibliothekGUI() {
|
||||
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());
|
||||
JLabel text1 = new JLabel("Login mit Kennnummer:");
|
||||
loginPanel.add(text1, BorderLayout.NORTH);
|
||||
dateButton.addActionListener(e -> {
|
||||
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());
|
||||
loginGrid.add(text1, BorderLayout.NORTH);
|
||||
JTextField field1 = new JTextField(20);
|
||||
loginGrid.add(field1);
|
||||
loginPanel.add(loginGrid, BorderLayout.CENTER);
|
||||
JButton b0 = new JButton("Registrieren");
|
||||
b0.addActionListener(e -> { nutzerAnlegen();});
|
||||
JButton b3 = new JButton("Ohne Anmeldung fortfahren");
|
||||
b3.addActionListener(e -> {
|
||||
browseMedia();
|
||||
});
|
||||
b3.addActionListener(e -> {browseMedia(datumArray[0]);});
|
||||
JPanel buttonGrid = new JPanel(new GridLayout(1,2,10,10));
|
||||
buttonGrid.add(b0);
|
||||
buttonGrid.add(b3);
|
||||
|
@ -47,7 +72,7 @@ public class BibliothekGUI extends JFrame implements ActionListener{
|
|||
String text = k.getClass().toString();
|
||||
int lastDotIndex = text.lastIndexOf(".");
|
||||
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(b2);
|
||||
|
@ -60,8 +85,53 @@ public class BibliothekGUI extends JFrame implements ActionListener{
|
|||
cl.show(mainPanel, "loginPanel");
|
||||
}
|
||||
|
||||
private void browseMedia() {
|
||||
JPanel browsePanel = new JPanel(new GridLayout(6, 1, 10, 10));
|
||||
private static void openMainMenu(Kunde k, String datum) {
|
||||
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");
|
||||
Kunde k = null;
|
||||
b1.addActionListener(e -> bookMenu(k));
|
||||
|
@ -73,18 +143,67 @@ public class BibliothekGUI extends JFrame implements ActionListener{
|
|||
b4.addActionListener(e -> bsMenu(k));
|
||||
JButton b5 = new JButton("Videospiele");
|
||||
b5.addActionListener(e -> vsMenu(k));
|
||||
JButton b6 = new JButton("OK");
|
||||
b6.addActionListener(e -> cl.show(mainPanel, "loginPanel"));
|
||||
JButton b6 = new JButton("Rückgabe");
|
||||
b6.addActionListener(e -> { rückgabeOhneUserID(datum);});
|
||||
JButton b7 = new JButton("Zurück");
|
||||
b7.addActionListener(e -> cl.show(mainPanel, "loginPanel"));
|
||||
browsePanel.add(b1);
|
||||
browsePanel.add(b2);
|
||||
browsePanel.add(b3);
|
||||
browsePanel.add(b4);
|
||||
browsePanel.add(b5);
|
||||
browsePanel.add(b6);
|
||||
browsePanel.add(b7);
|
||||
mainPanel.add(browsePanel, "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() {
|
||||
JPanel registerMenu = new JPanel(new BorderLayout());
|
||||
int newKennnummer = Bibliothek.getNewKennnummer();
|
||||
|
@ -194,11 +313,11 @@ public class BibliothekGUI extends JFrame implements ActionListener{
|
|||
mainPanel.add(changeOwedMenu, "changeOwed");
|
||||
cl.show(mainPanel, "changeOwed");
|
||||
}
|
||||
|
||||
private static void openMainMenu(Kunde k) {
|
||||
JPanel mediumPanel = new JPanel(new GridLayout(12, 1, 10, 10));
|
||||
JLabel text1 = new JLabel("Ihre Kennnnummer: " + k.getKennnummer());
|
||||
mediumPanel.add(text1);
|
||||
|
||||
private static void medienDurchsuchenMenu(Kunde k) {
|
||||
JPanel suchenPanel = new JPanel(new GridLayout(7,1,10,10));
|
||||
JButton b0 = new JButton("Stichwortsuche");
|
||||
b0.addActionListener(e -> searchMenu(k));
|
||||
JButton b1 = new JButton("Bücher");
|
||||
b1.addActionListener(e -> bookMenu(k));
|
||||
JButton b2 = new JButton("DVDs");
|
||||
|
@ -209,34 +328,59 @@ public class BibliothekGUI extends JFrame implements ActionListener{
|
|||
b4.addActionListener(e -> bsMenu(k));
|
||||
JButton b5 = new JButton("Videospiele");
|
||||
b5.addActionListener(e -> vsMenu(k));
|
||||
JButton b6 = new JButton("Ausleihe");
|
||||
b6.addActionListener(e -> ausleihenMenü(k));
|
||||
JButton b7 = new JButton("Rückgabe");
|
||||
b7.addActionListener(e -> rückgabeMenü(k));
|
||||
JButton b8 = new JButton("Meine Ausgeliehenen Medien");
|
||||
b8.addActionListener(e -> myBooks(k));
|
||||
JButton b9 = new JButton("Verlängern");
|
||||
b9.addActionListener(e -> verlängern(k));
|
||||
JButton b10 = new JButton("Meine Schulden abbezahlen");
|
||||
b10.addActionListener(e -> schuldenBegleichen(k));
|
||||
JButton b11 = new JButton("Ausloggen");
|
||||
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");
|
||||
JButton b6 = new JButton("Zurück");
|
||||
b6.addActionListener(e -> cl.show(mainPanel, "mediumPanel"));
|
||||
suchenPanel.add(b0);
|
||||
suchenPanel.add(b1);
|
||||
suchenPanel.add(b2);
|
||||
suchenPanel.add(b3);
|
||||
suchenPanel.add(b4);
|
||||
suchenPanel.add(b5);
|
||||
suchenPanel.add(b6);
|
||||
mainPanel.add(suchenPanel, "suchenMenu");
|
||||
cl.show(mainPanel, "suchenMenu");
|
||||
}
|
||||
|
||||
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());
|
||||
JLabel text0 = new JLabel("Geben Sie die Kennnumer des Mediums ein, dessen Rückgabezeit sie verlängern möchten.");
|
||||
JTextField inputField = new JTextField(20);
|
||||
|
@ -313,95 +457,95 @@ public class BibliothekGUI extends JFrame implements ActionListener{
|
|||
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 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:");
|
||||
JTextField inputField1 = new JTextField(20);
|
||||
JLabel text2 = new JLabel("Datum eingeben:");
|
||||
JTextField inputField2 = new JTextField(20);
|
||||
inputMenu.add(text1);
|
||||
inputMenu.add(inputField1);
|
||||
inputMenu.add(text2);
|
||||
inputMenu.add(inputField2);
|
||||
ausleihMenü.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");
|
||||
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(b2);
|
||||
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");
|
||||
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 inputMenu = new JPanel(new GridLayout(4,1,10,10));
|
||||
JLabel text1 = new JLabel("Kennnummer des Mediums zur Rückgabe eingeben:");
|
||||
//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ü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);
|
||||
JLabel text2 = new JLabel("Datum eingeben:");
|
||||
JTextField inputField2 = new JTextField(20);
|
||||
inputMenu.add(text1);
|
||||
inputMenu.add(inputField1);
|
||||
inputMenu.add(text2);
|
||||
inputMenu.add(inputField2);
|
||||
rückgabeMenü.add(inputMenu, BorderLayout.CENTER);;
|
||||
rückgabeMenü.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");
|
||||
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(b2);
|
||||
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");
|
||||
cl.show(mainPanel, "Rückgabe");
|
||||
}
|
||||
|
@ -420,7 +564,7 @@ public class BibliothekGUI extends JFrame implements ActionListener{
|
|||
if(k == null) {
|
||||
cl.show(mainPanel, "browsePanel");
|
||||
} else {
|
||||
cl.show(mainPanel, "mediumPanel");}
|
||||
cl.show(mainPanel, "suchenMenu");}
|
||||
});
|
||||
buchMenü.add(b1, BorderLayout.SOUTH);
|
||||
mainPanel.add(buchMenü, "Bücher");
|
||||
|
@ -441,7 +585,7 @@ public class BibliothekGUI extends JFrame implements ActionListener{
|
|||
if(k == null) {
|
||||
cl.show(mainPanel, "browsePanel");
|
||||
} else {
|
||||
cl.show(mainPanel, "mediumPanel");}
|
||||
cl.show(mainPanel, "suchenMenu");}
|
||||
});
|
||||
dvdMenü.add(b1, BorderLayout.SOUTH);
|
||||
mainPanel.add(dvdMenü, "DVDs");
|
||||
|
@ -462,7 +606,7 @@ public class BibliothekGUI extends JFrame implements ActionListener{
|
|||
if(k == null) {
|
||||
cl.show(mainPanel, "browsePanel");
|
||||
} else {
|
||||
cl.show(mainPanel, "mediumPanel");}
|
||||
cl.show(mainPanel, "suchenMenu");}
|
||||
}); cdMenü.add(b1, BorderLayout.SOUTH);
|
||||
mainPanel.add(cdMenü, "CDs");
|
||||
cl.show(mainPanel, "CDs");
|
||||
|
@ -482,7 +626,7 @@ public class BibliothekGUI extends JFrame implements ActionListener{
|
|||
if(k == null) {
|
||||
cl.show(mainPanel, "browsePanel");
|
||||
} else {
|
||||
cl.show(mainPanel, "mediumPanel");}
|
||||
cl.show(mainPanel, "suchenMenu");}
|
||||
}); bsMenü.add(b1, BorderLayout.SOUTH);
|
||||
mainPanel.add(bsMenü, "Brettspiele");
|
||||
cl.show(mainPanel, "Brettspiele");
|
||||
|
@ -502,7 +646,7 @@ public class BibliothekGUI extends JFrame implements ActionListener{
|
|||
if(k == null) {
|
||||
cl.show(mainPanel, "browsePanel");
|
||||
} else {
|
||||
cl.show(mainPanel, "mediumPanel");}
|
||||
cl.show(mainPanel, "suchenMenu");}
|
||||
}); vsMenü.add(b1, BorderLayout.SOUTH);
|
||||
mainPanel.add(vsMenü, "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) {
|
||||
JPanel zahlungPanel = new JPanel(new BorderLayout());
|
||||
JLabel text1 = new JLabel("Sie schulden für das Buch " + titel + " mit der Kennnummer " + kennnummer + " " + kosten + "€.");
|
||||
zahlungPanel.add(text1, BorderLayout.NORTH);
|
||||
JPanel zahlungPanelMitte = new JPanel(new GridLayout(2,1,10,10));
|
||||
JLabel text3 = new JLabel("Geben Sie ein wieviel sie zahlen:");
|
||||
zahlungPanelMitte.add(text3);
|
||||
JTextField inputField1 = new JTextField(20);
|
||||
zahlungPanelMitte.add(inputField1);
|
||||
zahlungPanel.add(zahlungPanelMitte, BorderLayout.CENTER);
|
||||
//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);
|
||||
mainPanel.add(zahlungPanel,"Zahlung1");
|
||||
cl.show(mainPanel, "Zahlung1");
|
||||
b1.addActionListener(e -> {
|
||||
String paymentString = inputField1.getText().toString();
|
||||
zahlungStatus(paymentString, kosten, k);
|
||||
b1.addActionListener(e -> {
|
||||
myBooks(k);
|
||||
});
|
||||
mainPanel.add(zahlungPanel,"Zahlung");
|
||||
cl.show(mainPanel, "Zahlung");
|
||||
}
|
||||
|
||||
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");
|
||||
});
|
||||
}
|
||||
|
||||
public static void noMoneyOwed() {
|
||||
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