Merge branch 'master' of https://gitty.informatik.hs-mannheim.de/3009594/Programmierung2.git
commit
e519effaf5
|
@ -0,0 +1,16 @@
|
|||
package Algorithmus;
|
||||
|
||||
public class Lueken_finden {
|
||||
|
||||
public static void main(String[] args) {
|
||||
for (int i = 0; i < Integer.MAX_VALUE; i++) {
|
||||
float f = i;
|
||||
|
||||
int merker = (int) f;
|
||||
|
||||
if (i != merker)
|
||||
System.out.println(i + " " + merker);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,137 @@
|
|||
package GUIAnwendungen.StudentManagementSystem;
|
||||
|
||||
import java.awt.EventQueue;
|
||||
|
||||
import javax.swing.JFrame;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.border.EmptyBorder;
|
||||
import java.awt.Color;
|
||||
import javax.swing.JLabel;
|
||||
import javax.swing.JButton;
|
||||
import javax.swing.JTextField;
|
||||
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 {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
private JPanel contentPane;
|
||||
private JTextField eingabeID;
|
||||
private JTextField eingabeName;
|
||||
private JTextField eingabeVorname;
|
||||
private JTextField einagbeGeburtstag;
|
||||
private JTextField eingabeTeleN;
|
||||
private JTextField eingabeAdresse;
|
||||
static JScrollPane listScrollPane = new JScrollPane();
|
||||
/**
|
||||
* Launch the application.
|
||||
*/
|
||||
public static void main(String[] args) {
|
||||
EventQueue.invokeLater(new Runnable() {
|
||||
public void run() {
|
||||
try {
|
||||
Login_Student frame = new Login_Student();
|
||||
frame.setVisible(true);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Create the frame.
|
||||
*/
|
||||
public Login_Student() {
|
||||
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
||||
setBounds(100, 100, 617, 421);
|
||||
contentPane = new JPanel();
|
||||
contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
|
||||
|
||||
setContentPane(contentPane);
|
||||
contentPane.setLayout(null);
|
||||
|
||||
JPanel panel = new JPanel();
|
||||
panel.setBackground(new Color(98, 160, 234));
|
||||
panel.setBounds(12, 28, 244, 381);
|
||||
contentPane.add(panel);
|
||||
panel.setLayout(null);
|
||||
|
||||
JLabel studentId = new JLabel("ID: ");
|
||||
studentId.setBounds(12, 12, 77, 17);
|
||||
panel.add(studentId);
|
||||
|
||||
JLabel name = new JLabel("Name: ");
|
||||
name.setBounds(12, 52, 98, 17);
|
||||
panel.add(name);
|
||||
|
||||
JLabel geburtstag = new JLabel("Geburtstag: ");
|
||||
geburtstag.setBounds(12, 130, 98, 17);
|
||||
panel.add(geburtstag);
|
||||
|
||||
JLabel geschlecht = new JLabel("Geschlecht:");
|
||||
geschlecht.setBounds(12, 170, 98, 17);
|
||||
panel.add(geschlecht);
|
||||
|
||||
JLabel tele = new JLabel("TeleN: ");
|
||||
tele.setBounds(12, 212, 60, 17);
|
||||
panel.add(tele);
|
||||
|
||||
JLabel adresse = new JLabel("Adresse: ");
|
||||
adresse.setBounds(12, 251, 60, 17);
|
||||
panel.add(adresse);
|
||||
|
||||
JLabel vorname = new JLabel("Vorname: ");
|
||||
vorname.setBounds(12, 91, 98, 17);
|
||||
panel.add(vorname);
|
||||
|
||||
JButton insertStudent = new JButton("Insert");
|
||||
insertStudent.setBounds(5, 294, 105, 27);
|
||||
panel.add(insertStudent);
|
||||
|
||||
JButton updateStudent = new JButton("Update");
|
||||
updateStudent.setBounds(127, 294, 105, 27);
|
||||
panel.add(updateStudent);
|
||||
|
||||
eingabeID = new JTextField();
|
||||
eingabeID.setBounds(118, 10, 114, 21);
|
||||
panel.add(eingabeID);
|
||||
eingabeID.setColumns(10);
|
||||
|
||||
eingabeName = new JTextField();
|
||||
eingabeName.setColumns(10);
|
||||
eingabeName.setBounds(118, 50, 114, 21);
|
||||
panel.add(eingabeName);
|
||||
|
||||
eingabeVorname = new JTextField();
|
||||
eingabeVorname.setColumns(10);
|
||||
eingabeVorname.setBounds(118, 89, 114, 21);
|
||||
panel.add(eingabeVorname);
|
||||
|
||||
einagbeGeburtstag = new JTextField();
|
||||
einagbeGeburtstag.setColumns(10);
|
||||
einagbeGeburtstag.setBounds(118, 128, 114, 21);
|
||||
panel.add(einagbeGeburtstag);
|
||||
|
||||
eingabeTeleN = new JTextField();
|
||||
eingabeTeleN.setColumns(10);
|
||||
eingabeTeleN.setBounds(118, 210, 114, 21);
|
||||
panel.add(eingabeTeleN);
|
||||
|
||||
eingabeAdresse = new JTextField();
|
||||
eingabeAdresse.setColumns(10);
|
||||
eingabeAdresse.setBounds(118, 249, 114, 21);
|
||||
panel.add(eingabeAdresse);
|
||||
|
||||
|
||||
|
||||
JList geshlechtAuswaehlen = new JList();
|
||||
geshlechtAuswaehlen.setToolTipText("");
|
||||
geshlechtAuswaehlen.setBounds(118, 170, 114, 17);
|
||||
panel.add(geshlechtAuswaehlen);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,20 @@
|
|||
package GUIAnwendungen.StudentManagementSystem;
|
||||
|
||||
public class Main {
|
||||
|
||||
public static void main(String[] args) {
|
||||
|
||||
Student st = new Student.StudenBuilder()
|
||||
.setName("Albek")
|
||||
.setVorname("Obai")
|
||||
.setAdresse("Gärtnerstr.25")
|
||||
.setEmail("Obai@gmail.com")
|
||||
.setGeburtstag("01.01.2001")
|
||||
.setGeschlecht('M')
|
||||
.setTele("00493213213")
|
||||
.setId(100)
|
||||
.build();
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,87 @@
|
|||
package GUIAnwendungen.StudentManagementSystem;
|
||||
|
||||
public class Student {
|
||||
|
||||
private String name;
|
||||
private String vorname;
|
||||
private char geschlecht;
|
||||
private String email;
|
||||
private String tele;
|
||||
private String adresse;
|
||||
private String geburtstag;
|
||||
private int id;
|
||||
|
||||
private Student(StudenBuilder student) {
|
||||
this.name = student.name;
|
||||
this.vorname = student.vorname;
|
||||
this.geschlecht = student.geschlecht;
|
||||
this.email = student.email;
|
||||
this.tele = student.tele;
|
||||
this.adresse = student.adresse;
|
||||
this.geburtstag = student.geburtstag;
|
||||
this.id = student.id;
|
||||
}
|
||||
|
||||
public static class StudenBuilder {
|
||||
private String name;
|
||||
private String vorname;
|
||||
private char geschlecht;
|
||||
private String email;
|
||||
private String tele;
|
||||
private String adresse;
|
||||
private String geburtstag;
|
||||
private int id;
|
||||
|
||||
|
||||
public StudenBuilder setName(String name) {
|
||||
this.name = name;
|
||||
return this;
|
||||
}
|
||||
|
||||
public StudenBuilder setVorname(String vorname) {
|
||||
this.vorname = vorname;
|
||||
return this;
|
||||
}
|
||||
|
||||
public StudenBuilder setGeschlecht(char geschlecht) {
|
||||
this.geschlecht = geschlecht;
|
||||
return this;
|
||||
}
|
||||
|
||||
public StudenBuilder setEmail(String email) {
|
||||
this.email = email;
|
||||
return this;
|
||||
}
|
||||
|
||||
public StudenBuilder setTele(String tele) {
|
||||
this.tele = tele;
|
||||
return this;
|
||||
}
|
||||
|
||||
public StudenBuilder setAdresse(String adresse) {
|
||||
this.adresse = adresse;
|
||||
return this;
|
||||
}
|
||||
|
||||
public StudenBuilder setGeburtstag(String geburtstag) {
|
||||
this.geburtstag = geburtstag;
|
||||
return this;
|
||||
}
|
||||
|
||||
public StudenBuilder setId(int id) {
|
||||
this.id = id;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Student build() {
|
||||
return new Student(this);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Student [name=" + name + ", vorname=" + vorname + ", geschlecht=" + geschlecht + ", email=" + email
|
||||
+ ", tele=" + tele + ", adresse=" + adresse + ", geburtstag=" + geburtstag + ", id=" + id + "]";
|
||||
}
|
||||
|
||||
}
|
Binary file not shown.
Binary file not shown.
|
@ -0,0 +1,21 @@
|
|||
package VorlesungsFolien;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class Gebäude {
|
||||
|
||||
private ArrayList<Hörsaal> räume = new ArrayList<>();
|
||||
|
||||
public int berechneGesamtzahlPlätze() {
|
||||
int plätze = 0;
|
||||
|
||||
for (Hörsaal h : this.räume)
|
||||
plätze += h.getPlätze();
|
||||
|
||||
return plätze;
|
||||
}
|
||||
|
||||
public void addHörsaal(Hörsaal hs) {
|
||||
this.räume.add(hs);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,20 @@
|
|||
package VorlesungsFolien;
|
||||
|
||||
public class Hörsaal {
|
||||
private int plätze;
|
||||
private String name;
|
||||
|
||||
Hörsaal(String name, int plätze) {
|
||||
this.name = name;
|
||||
this.plätze = plätze;
|
||||
}
|
||||
|
||||
public int getPlätze() {
|
||||
return plätze;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,14 @@
|
|||
package VorlesungsFolien;
|
||||
|
||||
public class Main {
|
||||
|
||||
public static void main(String[] args) {
|
||||
Gebäude a = new Gebäude();
|
||||
|
||||
a.addHörsaal(new Hörsaal("A210",50));
|
||||
a.addHörsaal(new Hörsaal("A212",40));
|
||||
|
||||
System.out.println(a.berechneGesamtzahlPlätze());
|
||||
}
|
||||
|
||||
}
|
Binary file not shown.
Binary file not shown.
After Width: | Height: | Size: 56 KiB |
|
@ -1,6 +1,8 @@
|
|||
package Übungen.MyChat_App;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Scanner;
|
||||
|
||||
|
||||
public class ChatRom {
|
||||
|
||||
|
@ -17,10 +19,8 @@ public class ChatRom {
|
|||
}
|
||||
|
||||
public void zeigeChatHistorie() {
|
||||
System.out.println("Chatverlauf:");
|
||||
for (String message : saveMessagesBetweenUsers)
|
||||
System.out.println(message);
|
||||
|
||||
for (String s : saveMessagesBetweenUsers)
|
||||
System.out.println(s);
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
|
@ -29,10 +29,21 @@ public class ChatRom {
|
|||
|
||||
ChatRom chatRoom = new ChatRom();
|
||||
|
||||
chatRoom.sendeNachricht(obai, omar, "Hallo Omar, wie geht es dir?");
|
||||
Scanner textEingabe = new Scanner(System.in);
|
||||
String message;
|
||||
while (true) {
|
||||
System.out.print("> ");
|
||||
message = textEingabe.nextLine();
|
||||
chatRoom.sendeNachricht(obai, omar, message);
|
||||
chatRoom.zeigeChatHistorie();
|
||||
|
||||
chatRoom.sendeNachricht(omar, obai, "Mir geht's gut, Obai. Danke!");
|
||||
System.out.print("> ");
|
||||
message = textEingabe.nextLine();
|
||||
chatRoom.sendeNachricht(omar, obai, message);
|
||||
|
||||
chatRoom.zeigeChatHistorie();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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