Shop
parent
7c7da5de0e
commit
9252ec44b7
|
@ -13,6 +13,7 @@ import javax.swing.JToggleButton;
|
|||
import javax.swing.JList;
|
||||
import javax.swing.AbstractListModel;
|
||||
import javax.swing.JRadioButton;
|
||||
import javax.swing.JScrollPane;
|
||||
import javax.swing.ListSelectionModel;
|
||||
|
||||
public class Login_Student extends JFrame {
|
||||
|
@ -25,7 +26,7 @@ public class Login_Student extends JFrame {
|
|||
private JTextField einagbeGeburtstag;
|
||||
private JTextField eingabeTeleN;
|
||||
private JTextField eingabeAdresse;
|
||||
|
||||
static JScrollPane listScrollPane = new JScrollPane();
|
||||
/**
|
||||
* Launch the application.
|
||||
*/
|
||||
|
@ -126,10 +127,7 @@ public class Login_Student extends JFrame {
|
|||
eingabeAdresse.setBounds(118, 249, 114, 21);
|
||||
panel.add(eingabeAdresse);
|
||||
|
||||
JList list = new JList();
|
||||
list.setValueIsAdjusting(true);
|
||||
list.setBounds(127, 169, 1, 1);
|
||||
panel.add(list);
|
||||
|
||||
|
||||
JList geshlechtAuswaehlen = new JList();
|
||||
geshlechtAuswaehlen.setToolTipText("");
|
||||
|
|
Binary file not shown.
|
@ -0,0 +1,38 @@
|
|||
package Übungen.OnlineShop;
|
||||
|
||||
public class Kunde {
|
||||
|
||||
private int id;
|
||||
private String name;
|
||||
private Warenkorb warenkorb;
|
||||
|
||||
public Kunde(int id, String name, Warenkorb warenkorb) {
|
||||
super();
|
||||
this.id = id;
|
||||
this.name = name;
|
||||
this.warenkorb = warenkorb;
|
||||
|
||||
}
|
||||
|
||||
public int getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(int id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Kunde [id=" + id + ", name=" + name + "]";
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,13 @@
|
|||
package Übungen.OnlineShop;
|
||||
|
||||
import java.io.FileNotFoundException;
|
||||
|
||||
public class Main {
|
||||
|
||||
public static void main(String[] args) throws FileNotFoundException {
|
||||
Shop shop = new Shop();
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,63 @@
|
|||
package Übungen.OnlineShop;
|
||||
|
||||
public class Produkt {
|
||||
private String name;
|
||||
private String beschreibung;
|
||||
private double preis;
|
||||
private int gewicht;
|
||||
private int bestand;
|
||||
|
||||
public Produkt(String name, String beschreibung, double preis, int gewicht, int bestand) {
|
||||
super();
|
||||
this.name = name;
|
||||
this.beschreibung = beschreibung;
|
||||
this.preis = preis;
|
||||
this.gewicht = gewicht;
|
||||
this.bestand = bestand;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getBeschreibung() {
|
||||
return beschreibung;
|
||||
}
|
||||
|
||||
public void setBeschreibung(String beschreibung) {
|
||||
this.beschreibung = beschreibung;
|
||||
}
|
||||
|
||||
public double getPreis() {
|
||||
return preis;
|
||||
}
|
||||
|
||||
public void setPreis(double preis) {
|
||||
this.preis = preis;
|
||||
}
|
||||
|
||||
public int getGewicht() {
|
||||
return gewicht;
|
||||
}
|
||||
|
||||
public void setGewicht(int gewicht) {
|
||||
this.gewicht = gewicht;
|
||||
}
|
||||
|
||||
public int getBestand() {
|
||||
return bestand;
|
||||
}
|
||||
|
||||
public void setBestand(int bestand) {
|
||||
this.bestand = bestand;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,9 @@
|
|||
package Übungen.OnlineShop;
|
||||
|
||||
public class ProduktNotFoundException extends Exception {
|
||||
|
||||
ProduktNotFoundException(String nachricht){
|
||||
super(nachricht);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,30 @@
|
|||
package Übungen.OnlineShop;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Scanner;
|
||||
|
||||
public class Shop {
|
||||
|
||||
ArrayList<Produkt> produkte;
|
||||
ArrayList<Kunde> kunde;
|
||||
ArrayList<Warenkorb> warenkorb;
|
||||
|
||||
Shop() throws FileNotFoundException {
|
||||
this.produkte = new ArrayList<>();
|
||||
this.kunde = new ArrayList<>();
|
||||
this.warenkorb = new ArrayList<>();
|
||||
addProdukte();
|
||||
}
|
||||
|
||||
public void addProdukte() throws FileNotFoundException {
|
||||
File fr = new File("/home/obai/git/Programmierung2/Programmierung2/src/Übungen/OnlineShop/produkte.csv");
|
||||
Scanner scan = new Scanner(fr);
|
||||
while (scan.hasNextLine())
|
||||
System.out.println(scan.nextLine());
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,44 @@
|
|||
package Übungen.OnlineShop;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class Warenkorb {
|
||||
private ArrayList<Produkt> produkte;
|
||||
|
||||
public Warenkorb(ArrayList<Produkt> produkte) {
|
||||
super();
|
||||
this.produkte = produkte;
|
||||
}
|
||||
|
||||
public void addProdukt(Produkt p) throws ProduktNotFoundException {
|
||||
if (p == null)
|
||||
throw new ProduktNotFoundException("Falsche Eingabe");
|
||||
|
||||
this.produkte.add(p);
|
||||
}
|
||||
|
||||
public void removeProdukt(Produkt p) throws ProduktNotFoundException {
|
||||
|
||||
for (Produkt pr: produkte)
|
||||
if (!pr.equals(p))
|
||||
throw new ProduktNotFoundException("Dieser Produkt ist bereits nicht im Warenkorb");
|
||||
|
||||
produkte.remove(p);
|
||||
}
|
||||
|
||||
public double gesamtPreisBerechnen() throws ProduktNotFoundException {
|
||||
|
||||
if (produkte.size() == 0)
|
||||
throw new ProduktNotFoundException("Sie haben keine Artikel ");
|
||||
|
||||
double gesamtPreis = 0;
|
||||
|
||||
for (Produkt pr: produkte)
|
||||
gesamtPreis += pr.getPreis();
|
||||
|
||||
return gesamtPreis;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,7 @@
|
|||
Name;Beschreibung;Preis;Gewicht;Bestand
|
||||
Gieskanne;Premium Gärtner-Gieskanne;3,99;250,00;17,00
|
||||
Hut;Perfekt für die Hutablage;21,98;120,00;123,00
|
||||
Dosenwurst;LWWRSCHT: das Pfälzer Original, nur kurz im Angebot;3,99;200,00;7,00
|
||||
Gartenschlauch;10 m, dehnbar bis auf die doppelte Länge;18,99;1300,00;23,00
|
||||
Schraubenset;100 zufällig ausgewählte Schrauben;2,99;287,00;99,00
|
||||
Akkuschrauber;Mit extra großem Drehmoment;25,00;900,00;13,00
|
|
Loading…
Reference in New Issue