added pay debts feature
parent
68914473f9
commit
36d06efb2f
|
@ -7,7 +7,6 @@ import java.time.format.DateTimeFormatter;
|
||||||
import java.time.temporal.ChronoUnit;
|
import java.time.temporal.ChronoUnit;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import javax.swing.JLabel;
|
import javax.swing.JLabel;
|
||||||
|
|
||||||
import guiBib.*;
|
import guiBib.*;
|
||||||
|
|
||||||
public class Bibliothek {
|
public class Bibliothek {
|
||||||
|
|
|
@ -18,7 +18,6 @@ abstract class Medium {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
class Buch extends Medium{
|
class Buch extends Medium{
|
||||||
private String titel;
|
private String titel;
|
||||||
private int erscheinungsjahr;
|
private int erscheinungsjahr;
|
||||||
|
|
|
@ -48,7 +48,7 @@ public class BibliothekGUI extends JFrame implements ActionListener{
|
||||||
cl.show(mainPanel, "loginPanel");
|
cl.show(mainPanel, "loginPanel");
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void openAdmin() {
|
private static void openAdmin() {
|
||||||
JPanel adminPanel = new JPanel(new BorderLayout());
|
JPanel adminPanel = new JPanel(new BorderLayout());
|
||||||
JPanel adminGrid = new JPanel(new GridLayout(2, 1, 10, 10));
|
JPanel adminGrid = new JPanel(new GridLayout(2, 1, 10, 10));
|
||||||
JLabel text1 = new JLabel("Admin-Bildschirm");
|
JLabel text1 = new JLabel("Admin-Bildschirm");
|
||||||
|
@ -85,8 +85,8 @@ public class BibliothekGUI extends JFrame implements ActionListener{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void openMainMenu(Kunde k) {
|
private static void openMainMenu(Kunde k) {
|
||||||
JPanel mediumPanel = new JPanel(new GridLayout(10, 1, 10, 10));
|
JPanel mediumPanel = new JPanel(new GridLayout(11, 1, 10, 10));
|
||||||
JLabel text1 = new JLabel("Ihre Kennnnummer: " + k.getKennnummer());
|
JLabel text1 = new JLabel("Ihre Kennnnummer: " + k.getKennnummer());
|
||||||
mediumPanel.add(text1);
|
mediumPanel.add(text1);
|
||||||
JButton b1 = new JButton("Bücher");
|
JButton b1 = new JButton("Bücher");
|
||||||
|
@ -105,8 +105,10 @@ public class BibliothekGUI extends JFrame implements ActionListener{
|
||||||
b7.addActionListener(e -> rückgabeMenü(k));
|
b7.addActionListener(e -> rückgabeMenü(k));
|
||||||
JButton b8 = new JButton("Meine Ausgeliehenen Medien");
|
JButton b8 = new JButton("Meine Ausgeliehenen Medien");
|
||||||
b8.addActionListener(e -> myBooks(k));
|
b8.addActionListener(e -> myBooks(k));
|
||||||
JButton b9 = new JButton("Ausloggen");
|
JButton b9 = new JButton("Meine Schulden abbezahlen");
|
||||||
b9.addActionListener(e -> cl.show(mainPanel, "loginPanel"));
|
b9.addActionListener(e -> schuldenBegleichen(k));
|
||||||
|
JButton b10 = new JButton("Ausloggen");
|
||||||
|
b10.addActionListener(e -> cl.show(mainPanel, "loginPanel"));
|
||||||
mediumPanel.add(b1);
|
mediumPanel.add(b1);
|
||||||
mediumPanel.add(b2);
|
mediumPanel.add(b2);
|
||||||
mediumPanel.add(b3);
|
mediumPanel.add(b3);
|
||||||
|
@ -116,10 +118,49 @@ public class BibliothekGUI extends JFrame implements ActionListener{
|
||||||
mediumPanel.add(b7);
|
mediumPanel.add(b7);
|
||||||
mediumPanel.add(b8);
|
mediumPanel.add(b8);
|
||||||
mediumPanel.add(b9);
|
mediumPanel.add(b9);
|
||||||
|
mediumPanel.add(b10);
|
||||||
mainPanel.add(mediumPanel, "mediumPanel");
|
mainPanel.add(mediumPanel, "mediumPanel");
|
||||||
cl.show(mainPanel, "mediumPanel");
|
cl.show(mainPanel, "mediumPanel");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
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;
|
||||||
|
System.out.println("neue Schulden: "+ newSchulden);
|
||||||
|
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) {
|
||||||
JPanel ausleihMenü = new JPanel(new BorderLayout());
|
JPanel ausleihMenü = new JPanel(new BorderLayout());
|
||||||
JPanel inputMenu = new JPanel(new GridLayout(4, 1, 10, 10));
|
JPanel inputMenu = new JPanel(new GridLayout(4, 1, 10, 10));
|
||||||
|
@ -313,6 +354,7 @@ public class BibliothekGUI extends JFrame implements ActionListener{
|
||||||
if(zahlungErfolgreich == true) {
|
if(zahlungErfolgreich == true) {
|
||||||
JLabel text4 = new JLabel("Zahlung war erfolgreich!");
|
JLabel text4 = new JLabel("Zahlung war erfolgreich!");
|
||||||
zahlungStatusPanel.add(text4, BorderLayout.CENTER);
|
zahlungStatusPanel.add(text4, BorderLayout.CENTER);
|
||||||
|
k.setSchulden(kosten - zahlung);
|
||||||
} else {
|
} else {
|
||||||
k.setSchulden(kosten - zahlung);
|
k.setSchulden(kosten - zahlung);
|
||||||
double schulden = k.getSchulden();
|
double schulden = k.getSchulden();
|
||||||
|
|
Loading…
Reference in New Issue