added Kunde class and wrote myBooks GUI method
parent
f13c38e510
commit
173c718940
|
@ -8,37 +8,6 @@ public abstract class Benutzer {
|
||||||
abstract public boolean istStudent();
|
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 {
|
class Mitarbeiter extends Benutzer {
|
||||||
private int kennnummer;
|
private int kennnummer;
|
||||||
|
|
||||||
|
|
|
@ -160,14 +160,38 @@ public class Bibliothek {
|
||||||
|
|
||||||
public static ArrayList<JLabel> vsAuflisten() {
|
public static ArrayList<JLabel> vsAuflisten() {
|
||||||
ArrayList<JLabel> jlabelList = new ArrayList<>();
|
ArrayList<JLabel> jlabelList = new ArrayList<>();
|
||||||
for(Brettspiel vs: brettspielListe) {
|
for(Videospiel v: videospielListe) {
|
||||||
JLabel vsp = new JLabel("Titel: " + vs.getTitel()
|
JLabel vsp = new JLabel("Titel: " + v.getTitel()
|
||||||
+ ", Jahr: " + vs.getJahr()
|
+ ", Jahr: " + v.getJahr()
|
||||||
+ ", Kennnummer: " + vs.getKennnummer());
|
+ ", Kennnummer: " + v.getKennnummer());
|
||||||
jlabelList.add(vsp);
|
jlabelList.add(vsp);
|
||||||
}
|
}
|
||||||
return jlabelList;
|
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 int erscheinungsjahr;
|
||||||
private String fälligkeitsDatum;
|
private String fälligkeitsDatum;
|
||||||
private int kennnummer;
|
private int kennnummer;
|
||||||
|
private String autor;
|
||||||
|
|
||||||
abstract public String getTitel();
|
abstract public String getTitel();
|
||||||
abstract public int getJahr();
|
abstract public int getJahr();
|
||||||
abstract public String getDatum();
|
abstract public String getDatum();
|
||||||
abstract public int getKennnummer();
|
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) {
|
private static void myBooks(Benutzer b) {
|
||||||
Kunde k = (Kunde) b;
|
Kunde k = (Kunde) b;
|
||||||
|
int i = k.ausgelieheneMedienLänge();
|
||||||
if(i == 0) {
|
if(i == 0) {
|
||||||
JPanel buchMenü = new JPanel(new BorderLayout());
|
JPanel myBookMenu = new JPanel(new BorderLayout());
|
||||||
JLabel text1 = new JLabel("Keine Bücher mehr vorhanden");
|
JLabel text1 = new JLabel("Keine Medien ausgeliehen");
|
||||||
buchMenü.add(text1, BorderLayout.NORTH);
|
myBookMenu.add(text1, BorderLayout.NORTH);
|
||||||
JButton b1 = new JButton("OK");
|
JButton b1 = new JButton("OK");
|
||||||
buchMenü.add(b1, BorderLayout.SOUTH);
|
myBookMenu.add(b1, BorderLayout.SOUTH);
|
||||||
mainPanel.add(buchMenü, "Bücher");
|
mainPanel.add(myBookMenu, "AusgelieheneMedien");
|
||||||
cl.show(mainPanel, "Bücher");
|
cl.show(mainPanel, "AusgelieheneMedien");
|
||||||
b1.addActionListener(e -> cl.show(mainPanel, "mediumPanel"));
|
b1.addActionListener(e -> cl.show(mainPanel, "mediumPanel"));
|
||||||
}
|
}
|
||||||
if(i != 0) {
|
if(i != 0) {
|
||||||
JPanel buchMenü = new JPanel(new GridLayout(i+1, 2, 10, 10));
|
JPanel myBookMenu = new JPanel(new GridLayout(i+1, 2, 10, 10));
|
||||||
ArrayList<JLabel> jlabelList = Bibliothek.buchAuflisten();
|
ArrayList<JLabel> jlabelList = Bibliothek.ausgelieheneListe(k);
|
||||||
for(JLabel j: jlabelList) {
|
for(JLabel j: jlabelList) {
|
||||||
buchMenü.add(j);
|
myBookMenu.add(j);
|
||||||
}
|
}
|
||||||
JButton b1 = new JButton("OK");
|
JButton b1 = new JButton("OK");
|
||||||
buchMenü.add(b1, BorderLayout.SOUTH);
|
myBookMenu.add(b1, BorderLayout.SOUTH);
|
||||||
mainPanel.add(buchMenü, "Bücher");
|
mainPanel.add(myBookMenu, "AusgelieheneMedien");
|
||||||
cl.show(mainPanel, "Bücher");
|
cl.show(mainPanel, "AusgelieheneMedien");
|
||||||
b1.addActionListener(e -> cl.show(mainPanel, "mediumPanel"));
|
b1.addActionListener(e -> cl.show(mainPanel, "mediumPanel"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
Loading…
Reference in New Issue