neues
parent
f8e9ae46b5
commit
3e24e2841b
|
@ -5,6 +5,11 @@
|
|||
<attribute name="module" value="true"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/5">
|
||||
<attributes>
|
||||
<attribute name="module" value="true"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry kind="src" path="src"/>
|
||||
<classpathentry kind="output" path="bin"/>
|
||||
</classpath>
|
||||
|
|
|
@ -0,0 +1,50 @@
|
|||
package BankSystemGUI;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileWriter;
|
||||
import java.io.IOException;
|
||||
import java.io.PrintWriter;
|
||||
|
||||
public class BankController {
|
||||
private File file;
|
||||
BankController(){
|
||||
file = new File("C:\\Users\\obaya\\git\\Programmierung2\\Programmierung2\\src\\BankSystemGUI\\Kunde.txt");
|
||||
if (!file.exists()) {
|
||||
try {
|
||||
if (file.createNewFile()) // createNewFile() gibt boolean zurück,ob der File ergolgreich erstellt wurde
|
||||
// oder nicht
|
||||
System.out.println("Datei erstellt: " + file.getName()); // der File muss im Pfad nicht existieren,
|
||||
// damit es erstellt wurde
|
||||
} catch (IOException d) {
|
||||
d.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public BankSystem addKunde(String name,String vorname,String password,String email) {
|
||||
BankSystem b1 = new BankSystem(name,vorname,password,email);
|
||||
saveKunde(b1);
|
||||
return b1;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public void saveKunde(BankSystem b1) {
|
||||
try (PrintWriter write = new PrintWriter(new FileWriter(file))) {
|
||||
write.println("ID: " + b1.getId());
|
||||
write.println("Vorname: " + b1.getVorname());
|
||||
write.println("Nachname: " + b1.getName());
|
||||
write.println("Password: " + b1.getPassword());
|
||||
write.println("Email: " + b1.getEmail());
|
||||
write.println("kontoStand " + b1.getKontoStand());
|
||||
write.println(); // Leere Zeile zwischen Einträgen
|
||||
write.flush();
|
||||
write.close();
|
||||
System.out.println(b1.toString());
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,93 @@
|
|||
package BankSystemGUI;
|
||||
|
||||
import java.awt.Dimension;
|
||||
import java.awt.FlowLayout;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
|
||||
import javax.swing.JFrame;
|
||||
import javax.swing.JTextField;
|
||||
// Recourses Klasse (Model)
|
||||
public class BankSystem {
|
||||
private String name;
|
||||
private String vorname;
|
||||
private String password;
|
||||
private String email;
|
||||
private double kontoStand;
|
||||
private int Id;
|
||||
private static int IDCounter = 0;
|
||||
|
||||
BankSystem(){}
|
||||
BankSystem(String name,String vorname,String password,String email){
|
||||
this.name = name;
|
||||
this.vorname = vorname;
|
||||
this.password = password;
|
||||
this.email = email;
|
||||
this.kontoStand = 0;
|
||||
this.Id = ++IDCounter;
|
||||
|
||||
}
|
||||
|
||||
public double einzahlung(double wert) {
|
||||
|
||||
return this.kontoStand += wert;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public int loadIDCounter() {
|
||||
return Id;
|
||||
}
|
||||
|
||||
public String getEmail() {
|
||||
return email;
|
||||
}
|
||||
|
||||
public void setEmail(String email) {
|
||||
this.email = email;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getVorname() {
|
||||
return vorname;
|
||||
}
|
||||
|
||||
public void setVorname(String vorname) {
|
||||
this.vorname = vorname;
|
||||
}
|
||||
|
||||
public String getPassword() {
|
||||
return password;
|
||||
}
|
||||
|
||||
public void setPassword(String password) {
|
||||
this.password = password;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public double getKontoStand() {
|
||||
return kontoStand;
|
||||
}
|
||||
|
||||
|
||||
public int getId() {
|
||||
return Id;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "BankSystem [name=" + name + ", vorname=" + vorname + ", password=" + password + ", kontoStand="
|
||||
+ kontoStand + ", Id=" + Id + "]";
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,14 @@
|
|||
package BankSystemGUI;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
public class BankSystemTest {
|
||||
|
||||
@Test
|
||||
public void testEinzahlung() {
|
||||
BankSystem test = new BankSystem();
|
||||
double x = test.einzahlung(100);
|
||||
assertEquals(100, x, 0.001); // Hier wird überprüft, ob der Kontostand 100.0 ist
|
||||
}
|
||||
}
|
|
@ -0,0 +1,57 @@
|
|||
package BankSystemGUI;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.util.Scanner;
|
||||
|
||||
import javax.swing.JLabel;
|
||||
|
||||
public class Hauptfenster extends BankSystem {
|
||||
private Window fenster;
|
||||
private Scanner scan;
|
||||
|
||||
Hauptfenster() throws FileNotFoundException{
|
||||
File fr = new File("C:\\Users\\obaya\\git\\Programmierung2\\Programmierung2\\src\\BankSystemGUI\\Kunde.txt");
|
||||
scan = new Scanner(fr);
|
||||
String vorname = null;
|
||||
String name = null;
|
||||
double kontoStand = 0.0;
|
||||
while (scan.hasNextLine()) {
|
||||
String line = scan.nextLine();
|
||||
// Prüfen, ob die Zeile den "Vorname" enthält
|
||||
if (line.startsWith("Vorname:"))
|
||||
vorname = line.split(":")[1].trim(); // Den Namen extrahieren
|
||||
|
||||
if (line.startsWith("Nachname: "))
|
||||
name = line.split(":")[1].trim();
|
||||
|
||||
if (line.startsWith("kontoStand ")) {
|
||||
String value = line.split(" ")[1].trim();
|
||||
kontoStand = Double.parseDouble(value);
|
||||
break; // Wir haben den Namen gefunden, also beenden wir die Schleife
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
fenster = new Window();
|
||||
fenster.setTitle("Haupseite");
|
||||
|
||||
JLabel willkommennachricht = new JLabel("Willkommen " + vorname + " " + name);
|
||||
willkommennachricht.setBounds(10, 10, 200, 40);
|
||||
|
||||
|
||||
JLabel konotstand = new JLabel("Deine Aktuelle Kontostand: " + kontoStand);
|
||||
konotstand.setBounds(10,50 ,200 ,40 );
|
||||
|
||||
|
||||
fenster.add(konotstand);
|
||||
fenster.add(willkommennachricht);
|
||||
}
|
||||
|
||||
public static void main(String[] args) throws FileNotFoundException {
|
||||
Hauptfenster test = new Hauptfenster();
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,7 @@
|
|||
ID: 1
|
||||
Vorname: obai
|
||||
Nachname: albek
|
||||
Password: 12345
|
||||
Email: obay@gmail.com
|
||||
kontoStand 0.0
|
||||
|
|
@ -0,0 +1,125 @@
|
|||
package BankSystemGUI;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.awt.Dimension;
|
||||
import java.awt.GridLayout;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.io.File;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.FileWriter;
|
||||
import java.io.IOException;
|
||||
import java.io.PrintWriter;
|
||||
|
||||
import javax.swing.JButton;
|
||||
import javax.swing.JFrame;
|
||||
import javax.swing.JLabel;
|
||||
import javax.swing.JOptionPane;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.JTextField;
|
||||
|
||||
public class LogIn extends JFrame implements ActionListener {
|
||||
private JButton submit;
|
||||
private File file;
|
||||
private PrintWriter write;
|
||||
private JTextField eingabeVorname;
|
||||
private JTextField eingabenNachname;
|
||||
private JTextField eingabenPassword;
|
||||
private JTextField eingabeEmail;
|
||||
private BankController controller;
|
||||
private Window fenster;
|
||||
|
||||
LogIn() {
|
||||
controller = new BankController();
|
||||
fenster = new Window();
|
||||
fenster.setTitle("log in Seite");
|
||||
|
||||
JLabel überschrift = new JLabel("loggen Sie sich ein: ");
|
||||
überschrift.setBounds(10, 2, 120, 40);
|
||||
|
||||
JLabel vorname = new JLabel("Vorname: ");
|
||||
vorname.setBounds(10, 50, 60, 10);
|
||||
eingabeVorname = new JTextField();
|
||||
eingabeVorname.setBounds(80, 50, 100, 20);
|
||||
|
||||
// setBounds(int x, int y, int width, int height)
|
||||
JLabel nachname = new JLabel("nachname: ");
|
||||
nachname.setBounds(10, 90, 100, 20);
|
||||
|
||||
eingabenNachname = new JTextField();
|
||||
eingabenNachname.setBounds(80, 90, 100, 20);
|
||||
|
||||
JLabel password = new JLabel("password: ");
|
||||
password.setBounds(10, 130, 100, 20);
|
||||
|
||||
eingabenPassword = new JTextField();
|
||||
eingabenPassword.setBounds(80, 130, 100, 20);
|
||||
|
||||
JLabel email = new JLabel("Email: ");
|
||||
email.setBounds(10, 170, 100, 20);
|
||||
|
||||
eingabeEmail = new JTextField();
|
||||
eingabeEmail.setBounds(80, 170, 100, 20);
|
||||
|
||||
submit = new JButton("Submit");
|
||||
submit.setBounds(10, 210, 100, 20);
|
||||
|
||||
submit.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
try {
|
||||
logUser();
|
||||
} catch (IOException e1) {
|
||||
// TODO Auto-generated catch block
|
||||
e1.printStackTrace();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
fenster.add(überschrift);
|
||||
fenster.add(vorname);
|
||||
fenster.add(eingabeVorname);
|
||||
fenster.add(nachname);
|
||||
fenster.add(eingabenNachname);
|
||||
fenster.add(password);
|
||||
fenster.add(eingabenPassword);
|
||||
fenster.add(email);
|
||||
fenster.add(eingabeEmail);
|
||||
fenster.add(submit);
|
||||
|
||||
}
|
||||
|
||||
public void logUser() throws IOException {
|
||||
if (eingabeVorname.getText().isEmpty() || eingabenNachname.getText().isEmpty()
|
||||
|| eingabenPassword.getText().isEmpty() || eingabeEmail.getText().isEmpty())
|
||||
JOptionPane.showMessageDialog(null, "Alle Felder sind erforderlich", "Fehler", JOptionPane.ERROR_MESSAGE);
|
||||
else {
|
||||
String vorname = eingabeVorname.getText();
|
||||
String nachname = eingabenNachname.getText();
|
||||
String password = eingabenPassword.getText();
|
||||
String email = eingabeEmail.getText();
|
||||
|
||||
BankSystem kunde = controller.addKunde(nachname, vorname, password, email);
|
||||
//JOptionPane.showMessageDialog(null, "Erfolgreich eingeloggt!", "Info", JOptionPane.INFORMATION_MESSAGE);
|
||||
fenster.dispose();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -0,0 +1,18 @@
|
|||
package BankSystemGUI;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class Test {
|
||||
|
||||
public static void main(String[] args) {
|
||||
|
||||
BankSystem b1 = new BankSystem("obai","albek","12345","obay@gmail.com");
|
||||
System.out.println(b1.toString());
|
||||
b1.einzahlung(100);
|
||||
System.out.println(b1.getKontoStand());
|
||||
System.out.println(b1.toString());
|
||||
//
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,22 @@
|
|||
package BankSystemGUI;
|
||||
|
||||
import java.awt.FlowLayout;
|
||||
import java.awt.GridLayout;
|
||||
|
||||
import javax.swing.JFrame;
|
||||
|
||||
public class Window extends JFrame {
|
||||
|
||||
public JFrame window;
|
||||
|
||||
Window(){
|
||||
|
||||
setSize(700, 700);
|
||||
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
||||
setLayout(null);
|
||||
setVisible(true);
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,16 @@
|
|||
package JunitTest;
|
||||
|
||||
public class Einführung {
|
||||
/*White-Box && Black-Box was ist das?
|
||||
* - Black-Box-Test: Du prüfst nur die Eingaben und Ausgaben, ohne den Code zu sehen oder zu verstehen. Es geht nur darum, ob die Software das Richtige tut.
|
||||
* - White-Box-Test: Du schaust dir den Code genau an und prüfst, ob jede Zeile und jedes Detail korrekt funktioniert. Hier verstehst du den Code und testest ihn gezielt.
|
||||
*/
|
||||
public static void main(String[] args) {
|
||||
|
||||
}
|
||||
|
||||
public int add(int a, int b) {
|
||||
return a+b;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,13 @@
|
|||
package JunitTest;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
public class EinführungTest {
|
||||
|
||||
@Test
|
||||
public void testAdd() {
|
||||
Einführung e1 = new Einführung();
|
||||
assertEquals(4, e1.add(2, 2));
|
||||
}
|
||||
}
|
|
@ -6,4 +6,6 @@
|
|||
*/
|
||||
module Programmierung2 {
|
||||
requires java.desktop;
|
||||
requires org.junit.jupiter.api;
|
||||
requires junit;
|
||||
}
|
Loading…
Reference in New Issue