Created more guis
parent
63b94b219f
commit
0eadf43183
|
@ -1,13 +1,22 @@
|
|||
package org.example;
|
||||
|
||||
import org.example.framework.framecreater;
|
||||
import org.example.objekts.Bibiliotek;
|
||||
import org.example.objekts.kunden;
|
||||
|
||||
import static org.example.objekts.Bibiliotek.addshit;
|
||||
import static org.example.objekts.Bibiliotek.kundenliste;
|
||||
|
||||
public class Main {
|
||||
public static void main(String[] args) {
|
||||
|
||||
//add the medien
|
||||
//admin
|
||||
kundenliste.add(new kunden(false,0));
|
||||
addshit();
|
||||
Bibiliotek.setAngemeldeterbenuter(-1);
|
||||
Bibiliotek.setFilter("Kein Filter");
|
||||
|
||||
framecreater.Startframe();
|
||||
|
||||
}
|
||||
|
|
|
@ -1,15 +1,17 @@
|
|||
package org.example.framework;
|
||||
|
||||
import org.example.objekts.Bibiliotek;
|
||||
import org.example.objekts.Medien;
|
||||
import org.example.objekts.kunden;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.time.DateTimeException;
|
||||
import java.time.LocalDate;
|
||||
import java.util.Date;
|
||||
import java.util.ArrayList;
|
||||
|
||||
import static java.lang.Thread.sleep;
|
||||
import static org.example.objekts.Bibiliotek.*;
|
||||
|
||||
|
||||
public class framecreater implements ActionListener {
|
||||
|
@ -19,15 +21,24 @@ public class framecreater implements ActionListener {
|
|||
//frame
|
||||
JFrame frame=new JFrame("Bibiliotek");
|
||||
JPanel panel=new JPanel();
|
||||
frame.setSize(700,700);
|
||||
frame.setSize(700,900);
|
||||
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
||||
frame.setVisible(true);
|
||||
frame.add(panel);
|
||||
panel.setLayout(null);
|
||||
|
||||
//anmelde button --> Chanche later if user is angemeldet
|
||||
JButton anemelden=new JButton("Anmelden");
|
||||
anemelden.setBounds(600,10,80,25);
|
||||
JButton anemelden=new JButton(Bibiliotek.getAngemeldeterbenuter()<0 ? "Anmelden" : "Profiel");
|
||||
anemelden.setBounds(600,10,90,25);
|
||||
anemelden.addActionListener(e -> {
|
||||
frame.dispose();
|
||||
if(getAngemeldeterbenuter()<0){
|
||||
anmeldeframe();
|
||||
} else {
|
||||
profilframe();
|
||||
}
|
||||
|
||||
});
|
||||
panel.add(anemelden);
|
||||
|
||||
//date button
|
||||
|
@ -44,6 +55,7 @@ public class framecreater implements ActionListener {
|
|||
filter.setBounds(10,10,80,25);
|
||||
filter.addActionListener(e -> {
|
||||
frame.dispose();
|
||||
Filterframe();
|
||||
});
|
||||
panel.add(filter);
|
||||
|
||||
|
@ -55,6 +67,40 @@ public class framecreater implements ActionListener {
|
|||
});
|
||||
panel.add(Sucher);
|
||||
|
||||
//create blocks for the inventory
|
||||
final int[] counter = {0};
|
||||
medienliste.forEach(m -> {
|
||||
if(m.getClass().getName().substring(20).equals(getFilter())){
|
||||
panel.add(createbutton(m,counter[0],frame));
|
||||
counter[0]++;
|
||||
} else if (getFilter().equals("Kein Filter")) {
|
||||
panel.add(createbutton(m,counter[0],frame));
|
||||
counter[0]++;
|
||||
} else if (getFilter().equals("Ausgeliehen") && m.getAusgeliehen()>0) {
|
||||
panel.add(createbutton(m,counter[0],frame));
|
||||
counter[0]++;
|
||||
} else if (getFilter().equals("Verfügbar") && m.getAusgeliehen()<=0) {
|
||||
panel.add(createbutton(m,counter[0],frame));
|
||||
counter[0]++;
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
}
|
||||
|
||||
public static JButton createbutton(Medien m, int counter, JFrame frame){
|
||||
JButton vorlage=new JButton("<html>"+m.getClass().getName().substring(20)
|
||||
+"<br>"+m.getTitel()
|
||||
+"<br>"+m.getBeschreibung()
|
||||
+"<br>"+m.getVerofentlichung()
|
||||
+"<br>"+(m.getAusgeliehen()!=0 ? "Ausgeliehen" : "Verfügbar")
|
||||
+"</html>");
|
||||
vorlage.setBounds(30+(80*(counter%8)),50+(100*(counter/10)),80,100 );
|
||||
vorlage.addActionListener(e -> {
|
||||
frame.dispose();
|
||||
Startframe();
|
||||
});
|
||||
return vorlage;
|
||||
}
|
||||
|
||||
public static void Zeitframe(){
|
||||
|
@ -117,7 +163,153 @@ public class framecreater implements ActionListener {
|
|||
}
|
||||
|
||||
public static void Filterframe(){
|
||||
//frame
|
||||
JFrame frame=new JFrame("Filter auswählen");
|
||||
JPanel panel=new JPanel();
|
||||
ArrayList<String> filterliste=new ArrayList<>();
|
||||
filterliste.add("Buch");
|
||||
filterliste.add("DVD");
|
||||
filterliste.add("CD");
|
||||
filterliste.add("Brettspiel");
|
||||
filterliste.add("Videospiel");
|
||||
filterliste.add("Ausgeliehen");
|
||||
filterliste.add("Verfügbar");
|
||||
filterliste.add("Kein Filter");
|
||||
frame.setSize(220,filterliste.size()*25+55);
|
||||
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
||||
frame.setVisible(true);
|
||||
frame.add(panel);
|
||||
panel.setLayout(null);
|
||||
|
||||
filterliste.forEach(s -> {
|
||||
//buch button
|
||||
JButton buch=new JButton(s);
|
||||
buch.setBounds(10,10+(25*filterliste.indexOf(s)),190,25);
|
||||
buch.addActionListener(e -> {
|
||||
frame.dispose();
|
||||
setFilter(s);
|
||||
Startframe();
|
||||
});
|
||||
panel.add(buch);
|
||||
});
|
||||
}
|
||||
|
||||
public static void anmeldeframe(){
|
||||
//frame
|
||||
JFrame frame=new JFrame("Anmelden");
|
||||
JPanel panel=new JPanel();
|
||||
frame.setSize(400,200);
|
||||
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
||||
frame.setVisible(true);
|
||||
frame.add(panel);
|
||||
panel.setLayout(null);
|
||||
|
||||
//text feld
|
||||
JLabel text=new JLabel("Bitte gib deine Kundennummer ein:");
|
||||
text.setBounds(10,70,400,25);
|
||||
panel.add(text);
|
||||
|
||||
//date feld
|
||||
JTextField jear=new JTextField(20);
|
||||
jear.setBounds(10,100,100,25);
|
||||
panel.add(jear);
|
||||
|
||||
//succes button
|
||||
JButton succes=new JButton("Anmelden");
|
||||
succes.setBounds(90,130,90,25);
|
||||
succes.addActionListener( e -> {
|
||||
try {
|
||||
if(kundenliste.get(Integer.valueOf(jear.getText()))!=null){
|
||||
setAngemeldeterbenuter(Integer.valueOf(jear.getText()));
|
||||
frame.dispose();
|
||||
Startframe();
|
||||
} else {
|
||||
text.setText("Falsche Nummer, bitte versuche es erneut");
|
||||
}
|
||||
} catch (NumberFormatException ec){
|
||||
text.setText("Falsche Nummer, bitte versuche es erneut");
|
||||
} catch (IndexOutOfBoundsException ec){
|
||||
text.setText("Falsche Nummer, bitte versuche es erneut");
|
||||
}
|
||||
});
|
||||
panel.add(succes);
|
||||
|
||||
//regestrieren button
|
||||
JButton regestrieren=new JButton("Registrieren");
|
||||
regestrieren.setBounds(180,130,80,25);
|
||||
regestrieren.addActionListener( e -> {
|
||||
kundenliste.add(new kunden(false,(kundenliste.size())));
|
||||
setAngemeldeterbenuter(kundenliste.size()-1);
|
||||
frame.dispose();
|
||||
Startframe();
|
||||
});
|
||||
panel.add(regestrieren);
|
||||
|
||||
//back button
|
||||
JButton back=new JButton("Zurück");
|
||||
back.setBounds(10,130,80,25);
|
||||
back.addActionListener(e -> {
|
||||
frame.dispose();
|
||||
Startframe();
|
||||
});
|
||||
panel.add(back);
|
||||
}
|
||||
|
||||
public static void profilframe(){
|
||||
//frame
|
||||
JFrame frame=new JFrame("Profil");
|
||||
JPanel panel=new JPanel();
|
||||
frame.setSize(400,800);
|
||||
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
||||
frame.setVisible(true);
|
||||
frame.add(panel);
|
||||
panel.setLayout(null);
|
||||
|
||||
kunden k=kundenliste.get(getAngemeldeterbenuter());
|
||||
|
||||
//text feld
|
||||
JLabel nummer=new JLabel("Kunden Nummer: "+(k.getnummer()));
|
||||
nummer.setBounds(10,10,200,25);
|
||||
panel.add(nummer);
|
||||
|
||||
//text feld
|
||||
JLabel schulden=new JLabel("Schulden: "+k.getSchulden());
|
||||
schulden.setBounds( 10,30,200,25);
|
||||
panel.add(schulden);
|
||||
|
||||
//studentstatus feld
|
||||
JLabel studentstatus=new JLabel("Student/Schühler: "+( k.isIstStudent()? "Ja" : "Nein"));
|
||||
studentstatus.setBounds(10,50,200,25);
|
||||
panel.add(studentstatus);
|
||||
|
||||
//studentstatus button
|
||||
JButton succes=new JButton("Ändern");
|
||||
succes.setBounds(170,50,80,25);
|
||||
succes.addActionListener( e -> {
|
||||
frame.dispose();
|
||||
k.setIstStudent(!k.isIstStudent());
|
||||
profilframe();
|
||||
});
|
||||
panel.add(succes);
|
||||
|
||||
//back button
|
||||
JButton back=new JButton("Zurück");
|
||||
back.setBounds(10,725,80,25);
|
||||
back.addActionListener(e -> {
|
||||
frame.dispose();
|
||||
Startframe();
|
||||
});
|
||||
panel.add(back);
|
||||
|
||||
//back button
|
||||
JButton abmelden=new JButton("Abmelden");
|
||||
abmelden.setBounds(90,725,100,25);
|
||||
abmelden.addActionListener(e -> {
|
||||
frame.dispose();
|
||||
setAngemeldeterbenuter(-1);
|
||||
Startframe();
|
||||
});
|
||||
panel.add(abmelden);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -9,6 +9,11 @@ public class Bibiliotek {
|
|||
public static ArrayList<Medien> medienliste=new ArrayList<>();
|
||||
public static ArrayList<kunden> kundenliste=new ArrayList<>();
|
||||
|
||||
private static int Angemeldeterbenuter;
|
||||
|
||||
private static String Filter;
|
||||
|
||||
|
||||
// Global system date, initialized to the current date
|
||||
private static LocalDate datum = LocalDate.now();
|
||||
|
||||
|
@ -22,9 +27,43 @@ public class Bibiliotek {
|
|||
datum = newDate;
|
||||
}
|
||||
|
||||
public static int getAngemeldeterbenuter() {
|
||||
return Angemeldeterbenuter;
|
||||
}
|
||||
|
||||
public static void setAngemeldeterbenuter(int angemeldeterbenuter) {
|
||||
Angemeldeterbenuter = angemeldeterbenuter;
|
||||
}
|
||||
|
||||
public static String getFilter() {
|
||||
return Filter;
|
||||
}
|
||||
|
||||
public static void setFilter(String filter) {
|
||||
Filter = filter;
|
||||
}
|
||||
|
||||
public static void addshit(){
|
||||
medienliste.add(new Buch("Schmi","","",1));
|
||||
for (Medien m : medienliste) if(m instanceof Buch) System.out.println(true);
|
||||
|
||||
medienliste.add(new DVD("Schmi2","","s",1));
|
||||
medienliste.add(new Buch("Schmi3","","s",1));
|
||||
medienliste.add(new Buch("Schmi4","","",1));
|
||||
medienliste.add(new Buch("Schmi5","","",1));
|
||||
medienliste.add(new Buch("Schmi6","","as",1));
|
||||
medienliste.add(new Buch("Schmi6","","as",1));
|
||||
medienliste.add(new Buch("Schmi6","","as",1));
|
||||
medienliste.add(new DVD("Schmi6","","as",1));
|
||||
medienliste.add(new Buch("Schmi6","","as",1));
|
||||
medienliste.add(new Buch("Schmi6","","as",1));
|
||||
medienliste.add(new Buch("Schmi6","","as",1));
|
||||
medienliste.add(new Buch("Schmi6","","as",1));
|
||||
medienliste.add(new Buch("Schmi6","","as",1));
|
||||
medienliste.add(new Buch("Schmi6","","as",1));
|
||||
medienliste.add(new Buch("Schmi6","","as",1));
|
||||
medienliste.add(new DVD("Schmi6","","as",1));
|
||||
medienliste.add(new Buch("Schmi6","","as",1));
|
||||
medienliste.add(new Buch("Schmi6","","as",1));
|
||||
medienliste.add(new Buch("Schmi6","","as",1));
|
||||
medienliste.add(new Buch("Schmi6","","as",1));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
package org.example.objekts;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
|
||||
|
@ -41,4 +40,8 @@ public class kunden {
|
|||
public void setAusgeliehen(HashMap<Medien, Date> ausgeliehen) {
|
||||
this.ausgeliehen = ausgeliehen;
|
||||
}
|
||||
|
||||
public void setIstStudent(boolean istStudent) {
|
||||
this.istStudent = istStudent;
|
||||
}
|
||||
}
|
||||
|
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading…
Reference in New Issue