added Kunde class and wrote myBooks GUI method
parent
f13c38e510
commit
173c718940
|
@ -8,37 +8,6 @@ public abstract class Benutzer {
|
|||
abstract public boolean istStudent();
|
||||
}
|
||||
|
||||
class Kunde extends Benutzer {
|
||||
private int kennnummer;
|
||||
private boolean istStudent;
|
||||
private ArrayList<Medium> ausgelieheneMedien = new ArrayList<>();
|
||||
|
||||
public Kunde(boolean istStudent, int kennnummer) {
|
||||
this.istStudent = istStudent;
|
||||
this.kennnummer = kennnummer;
|
||||
}
|
||||
|
||||
public int getKennnummer() {
|
||||
return kennnummer;
|
||||
}
|
||||
|
||||
public void addToList(Medium m) {
|
||||
ausgelieheneMedien.add(m);
|
||||
}
|
||||
|
||||
public boolean istStudent() {
|
||||
return istStudent;
|
||||
}
|
||||
|
||||
public ArrayList<Medium> returnAusgeliehen(){
|
||||
return ausgelieheneMedien;
|
||||
}
|
||||
|
||||
public int ausgelieheneMedienLänge() {
|
||||
return ausgelieheneMedien.size();
|
||||
}
|
||||
}
|
||||
|
||||
class Mitarbeiter extends Benutzer {
|
||||
private int kennnummer;
|
||||
|
||||
|
|
|
@ -160,14 +160,38 @@ public class Bibliothek {
|
|||
|
||||
public static ArrayList<JLabel> vsAuflisten() {
|
||||
ArrayList<JLabel> jlabelList = new ArrayList<>();
|
||||
for(Brettspiel vs: brettspielListe) {
|
||||
JLabel vsp = new JLabel("Titel: " + vs.getTitel()
|
||||
+ ", Jahr: " + vs.getJahr()
|
||||
+ ", Kennnummer: " + vs.getKennnummer());
|
||||
for(Videospiel v: videospielListe) {
|
||||
JLabel vsp = new JLabel("Titel: " + v.getTitel()
|
||||
+ ", Jahr: " + v.getJahr()
|
||||
+ ", Kennnummer: " + v.getKennnummer());
|
||||
jlabelList.add(vsp);
|
||||
}
|
||||
return jlabelList;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public static ArrayList<JLabel> ausgelieheneListe(Kunde k) {
|
||||
ArrayList<JLabel> jlabelList = new ArrayList<>();
|
||||
for(Medium m: k.returnAusgelieheneMedien()) {
|
||||
if(m.getAutor() != null) {
|
||||
JLabel med = new JLabel("Titel: " + m.getTitel()
|
||||
+ ", Autor: " + m.getAutor()
|
||||
+ ", Jahr: " + m.getJahr()
|
||||
+ ", Kennnummer: " +m.getKennnummer());
|
||||
}
|
||||
if(m.getAutor() == null) {
|
||||
JLabel med = new JLabel("Titel: " + m.getTitel()
|
||||
+ ", Jahr: " + m.getJahr()
|
||||
+ ", Kennnummer: " +m.getKennnummer());
|
||||
jlabelList.add(med);
|
||||
}
|
||||
}
|
||||
return jlabelList;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -0,0 +1,34 @@
|
|||
package domainBib;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class Kunde extends Benutzer {
|
||||
private int kennnummer;
|
||||
private boolean istStudent;
|
||||
private ArrayList<Medium> ausgelieheneMedien = new ArrayList<>();
|
||||
|
||||
public Kunde(boolean istStudent, int kennnummer) {
|
||||
this.istStudent = istStudent;
|
||||
this.kennnummer = kennnummer;
|
||||
}
|
||||
|
||||
public int getKennnummer() {
|
||||
return kennnummer;
|
||||
}
|
||||
|
||||
public void addToList(Medium m) {
|
||||
ausgelieheneMedien.add(m);
|
||||
}
|
||||
|
||||
public boolean istStudent() {
|
||||
return istStudent;
|
||||
}
|
||||
|
||||
public ArrayList<Medium> returnAusgelieheneMedien(){
|
||||
return ausgelieheneMedien;
|
||||
}
|
||||
|
||||
public int ausgelieheneMedienLänge() {
|
||||
return ausgelieheneMedien.size();
|
||||
}
|
||||
}
|
|
@ -5,11 +5,15 @@ abstract class Medium {
|
|||
private int erscheinungsjahr;
|
||||
private String fälligkeitsDatum;
|
||||
private int kennnummer;
|
||||
private String autor;
|
||||
|
||||
abstract public String getTitel();
|
||||
abstract public int getJahr();
|
||||
abstract public String getDatum();
|
||||
abstract public int getKennnummer();
|
||||
public String getAutor() {
|
||||
return autor;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -213,30 +213,31 @@ public class BibliothekGUI extends JFrame implements ActionListener{
|
|||
|
||||
private static void myBooks(Benutzer b) {
|
||||
Kunde k = (Kunde) b;
|
||||
int i = k.ausgelieheneMedienLänge();
|
||||
if(i == 0) {
|
||||
JPanel buchMenü = new JPanel(new BorderLayout());
|
||||
JLabel text1 = new JLabel("Keine Bücher mehr vorhanden");
|
||||
buchMenü.add(text1, BorderLayout.NORTH);
|
||||
JPanel myBookMenu = new JPanel(new BorderLayout());
|
||||
JLabel text1 = new JLabel("Keine Medien ausgeliehen");
|
||||
myBookMenu.add(text1, BorderLayout.NORTH);
|
||||
JButton b1 = new JButton("OK");
|
||||
buchMenü.add(b1, BorderLayout.SOUTH);
|
||||
mainPanel.add(buchMenü, "Bücher");
|
||||
cl.show(mainPanel, "Bücher");
|
||||
myBookMenu.add(b1, BorderLayout.SOUTH);
|
||||
mainPanel.add(myBookMenu, "AusgelieheneMedien");
|
||||
cl.show(mainPanel, "AusgelieheneMedien");
|
||||
b1.addActionListener(e -> cl.show(mainPanel, "mediumPanel"));
|
||||
}
|
||||
if(i != 0) {
|
||||
JPanel buchMenü = new JPanel(new GridLayout(i+1, 2, 10, 10));
|
||||
ArrayList<JLabel> jlabelList = Bibliothek.buchAuflisten();
|
||||
JPanel myBookMenu = new JPanel(new GridLayout(i+1, 2, 10, 10));
|
||||
ArrayList<JLabel> jlabelList = Bibliothek.ausgelieheneListe(k);
|
||||
for(JLabel j: jlabelList) {
|
||||
buchMenü.add(j);
|
||||
myBookMenu.add(j);
|
||||
}
|
||||
JButton b1 = new JButton("OK");
|
||||
buchMenü.add(b1, BorderLayout.SOUTH);
|
||||
mainPanel.add(buchMenü, "Bücher");
|
||||
cl.show(mainPanel, "Bücher");
|
||||
myBookMenu.add(b1, BorderLayout.SOUTH);
|
||||
mainPanel.add(myBookMenu, "AusgelieheneMedien");
|
||||
cl.show(mainPanel, "AusgelieheneMedien");
|
||||
b1.addActionListener(e -> cl.show(mainPanel, "mediumPanel"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
|
|
Loading…
Reference in New Issue