parent
bdb34ab86b
commit
3e70dacdc2
|
@ -317,6 +317,26 @@ public class Bibliothek {
|
|||
return videospielListe.size();
|
||||
}
|
||||
|
||||
public static int getUserListLength() {
|
||||
return kundenListe.size();
|
||||
}
|
||||
|
||||
public static ArrayList<JLabel> nutzerAuflisten() {
|
||||
ArrayList<JLabel> jlabelList = new ArrayList<>();
|
||||
if(kundenListe.size() == 0) {
|
||||
JLabel text = new JLabel("Keine Nutzer registriert.");
|
||||
jlabelList.add(text);
|
||||
return jlabelList;
|
||||
}
|
||||
for(Kunde k: kundenListe) {
|
||||
JLabel cd = new JLabel("Kennnummer: " + k.getKennnummer()
|
||||
+ ", Student: " + k.istStudent());
|
||||
jlabelList.add(cd);
|
||||
}
|
||||
return jlabelList;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -5,17 +5,31 @@ import java.util.ArrayList;
|
|||
public class Kunde extends Benutzer {
|
||||
private int kennnummer;
|
||||
private boolean istStudent;
|
||||
private double schulden;
|
||||
private ArrayList<Medium> ausgelieheneMedien = new ArrayList<>();
|
||||
|
||||
public Kunde(boolean istStudent, int kennnummer) {
|
||||
this.istStudent = istStudent;
|
||||
this.kennnummer = kennnummer;
|
||||
this.schulden = 0;
|
||||
}
|
||||
|
||||
public int getKennnummer() {
|
||||
return kennnummer;
|
||||
}
|
||||
|
||||
public void setSchulden(double a) {
|
||||
schulden = a;
|
||||
}
|
||||
|
||||
public void addSchulden(double b) {
|
||||
schulden += b;
|
||||
}
|
||||
|
||||
public double getSchulden(){
|
||||
return schulden;
|
||||
}
|
||||
|
||||
public void addToList(Medium m) {
|
||||
ausgelieheneMedien.add(m);
|
||||
}
|
||||
|
|
|
@ -29,14 +29,13 @@ public class BibliothekGUI extends JFrame implements ActionListener{
|
|||
b2.addActionListener(e -> {
|
||||
String loginStr = field1.getText();
|
||||
Integer login = Integer.parseInt(loginStr);
|
||||
if(login == 1) {openAdmin();}else {
|
||||
Kunde k = Bibliothek.validateLogin(login);
|
||||
if(k == null) {dispose();}
|
||||
String text = k.getClass().toString();
|
||||
int lastDotIndex = text.lastIndexOf(".");
|
||||
String substring = text.substring(lastDotIndex + 1);
|
||||
if(substring.equals("Kunde")) {openMainMenu(k);}
|
||||
if(substring.equals("Mitarbeiter")) {openAdmin();}
|
||||
});
|
||||
}});
|
||||
bp.add(b1);
|
||||
bp.add(b2);
|
||||
loginPanel.add(bp, BorderLayout.SOUTH);
|
||||
|
@ -49,15 +48,47 @@ public class BibliothekGUI extends JFrame implements ActionListener{
|
|||
}
|
||||
|
||||
public static void openAdmin() {
|
||||
JPanel adminPanel = new JPanel(new BorderLayout());
|
||||
JPanel adminGrid = new JPanel(new GridLayout(2, 1, 10, 10));
|
||||
JLabel text1 = new JLabel("Admin-Bildschirm");
|
||||
adminPanel.add(text1, BorderLayout.NORTH);
|
||||
JButton b0 = new JButton("Ausloggen");
|
||||
b0.addActionListener(e -> cl.show(mainPanel, "loginPanel"));
|
||||
adminPanel.add(b0, BorderLayout.SOUTH);
|
||||
JButton b1 = new JButton("Liste aller Kunden ansehen");
|
||||
b1.addActionListener(e -> userListMenu());
|
||||
JButton b2 = new JButton("Gebühren überschreiben");
|
||||
b2.addActionListener(e -> userOwedMenu());
|
||||
adminGrid.add(b1);
|
||||
adminGrid.add(b2);
|
||||
adminPanel.add(adminGrid, BorderLayout.CENTER);
|
||||
mainPanel.add(adminPanel, "adminMenu");
|
||||
cl.show(mainPanel, "adminMenu");
|
||||
}
|
||||
|
||||
private static void userListMenu() {
|
||||
int i = Bibliothek.getUserListLength();
|
||||
JPanel userListPanel = new JPanel(new GridLayout(i+1, 2, 10, 10));
|
||||
ArrayList<JLabel> jlabelList = Bibliothek.nutzerAuflisten();
|
||||
for(JLabel j: jlabelList) {
|
||||
userListPanel.add(j);
|
||||
}
|
||||
JButton b1 = new JButton("OK");
|
||||
b1.addActionListener(e -> cl.show(mainPanel, "adminMenu"));
|
||||
userListPanel.add(b1, BorderLayout.SOUTH);
|
||||
mainPanel.add(userListPanel, "userList");
|
||||
cl.show(mainPanel, "userList");
|
||||
}
|
||||
|
||||
|
||||
private static void userOwedMenu() {
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public static void openMainMenu(Kunde k) {
|
||||
JPanel mediumPanel = new JPanel(new GridLayout(10, 1, 10, 10));
|
||||
JTextField text1 = new JTextField("Nutzer: " + k.getKennnummer());
|
||||
JLabel text1 = new JLabel("Ihre Kennnnummer: " + k.getKennnummer());
|
||||
mediumPanel.add(text1);
|
||||
JButton b1 = new JButton("Bücher");
|
||||
b1.addActionListener(e -> bookMenu());
|
||||
|
@ -86,7 +117,6 @@ public class BibliothekGUI extends JFrame implements ActionListener{
|
|||
mediumPanel.add(b7);
|
||||
mediumPanel.add(b8);
|
||||
mediumPanel.add(b9);
|
||||
|
||||
mainPanel.add(mediumPanel, "mediumPanel");
|
||||
cl.show(mainPanel, "mediumPanel");
|
||||
}
|
||||
|
@ -126,7 +156,7 @@ public class BibliothekGUI extends JFrame implements ActionListener{
|
|||
b2.addActionListener(e -> {
|
||||
int kennnummer = Integer.parseInt(inputField.getText());
|
||||
Bibliothek.rückgabe(kennnummer, k);
|
||||
cl.show(mainPanel, "mediumPanel");
|
||||
myBooks(k);
|
||||
});
|
||||
buttonGrid.add(b1);
|
||||
buttonGrid.add(b2);
|
||||
|
@ -209,14 +239,18 @@ public class BibliothekGUI extends JFrame implements ActionListener{
|
|||
|
||||
private static void myBooks(Kunde k) {
|
||||
int i = k.ausgelieheneMedienLänge();
|
||||
JPanel myBookMenu = new JPanel(new GridLayout(i+1, 2, 10, 10));
|
||||
JPanel myBookMenu = new JPanel(new BorderLayout());
|
||||
JPanel info = new JPanel(new GridLayout(i, 1, 10, 10));
|
||||
JLabel text1 = new JLabel("Ihre ausgeliehenen Medien:");
|
||||
myBookMenu.add(text1, BorderLayout.NORTH);
|
||||
ArrayList<JLabel> jlabelList = Bibliothek.ausgelieheneListe(k);
|
||||
for(JLabel j: jlabelList) {
|
||||
myBookMenu.add(j);
|
||||
info.add(j);
|
||||
}
|
||||
JButton b1 = new JButton("OK");
|
||||
b1.addActionListener(e -> cl.show(mainPanel, "mediumPanel"));
|
||||
myBookMenu.add(b1);
|
||||
myBookMenu.add(info, BorderLayout.CENTER);
|
||||
myBookMenu.add(b1, BorderLayout.SOUTH);
|
||||
mainPanel.add(myBookMenu, "AusgelieheneMedien");
|
||||
cl.show(mainPanel, "AusgelieheneMedien");
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue