added register new user feature

verlängerungFeature
Berat Kocak 2024-11-10 19:06:24 +01:00
parent db2ee4f093
commit 560dca7110
2 changed files with 38 additions and 2 deletions

View File

@ -510,6 +510,22 @@ public class Bibliothek {
} }
return jlabelList; return jlabelList;
} }
public static int getNewKennnummer() {
int newKennnummer = 0;
for(Kunde k: kundenListe) {
int nummer = k.getKennnummer();
if(nummer > newKennnummer) {
newKennnummer = nummer;
}
}
newKennnummer += 1;
return newKennnummer;
}
public static void addCustomer(Kunde k) {
kundenListe.add(k);
}
} }

View File

@ -86,8 +86,28 @@ public class BibliothekGUI extends JFrame implements ActionListener{
} }
private void nutzerAnlegen() { private void nutzerAnlegen() {
// TODO Auto-generated method stub JPanel registerMenu = new JPanel(new BorderLayout());
int newKennnummer = Bibliothek.getNewKennnummer();
JLabel text0 = new JLabel("Ihre Kennnummmer wird " + newKennnummer + " sein.");
JCheckBox studentOrNot = new JCheckBox("Sind Sie Student? Falls ja bitte anklicken.");
registerMenu.add(text0, BorderLayout.NORTH);
registerMenu.add(studentOrNot, BorderLayout.CENTER);
final boolean[] isStudent = {false};
studentOrNot.addActionListener(e -> isStudent[0] = studentOrNot.isSelected());
JPanel bg = new JPanel(new GridLayout(1,2,10,10));
JButton b2 = new JButton("OK");
b2.addActionListener(e -> {
Kunde k = new Kunde(isStudent[0], newKennnummer);
Bibliothek.addCustomer(k);
cl.show(mainPanel, "loginPanel");
});
JButton b1 = new JButton("Abbrechen");
b1.addActionListener(e -> cl.show(mainPanel, "loginPanel"));
bg.add(b1);
bg.add(b2);
registerMenu.add(bg, BorderLayout.SOUTH);
mainPanel.add(registerMenu, "registerMenu");
cl.show(mainPanel, "registerMenu");
} }
private static void openAdmin() { private static void openAdmin() {