mein erstes
commit
27a4843ce5
|
@ -0,0 +1,10 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<classpath>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-22">
|
||||
<attributes>
|
||||
<attribute name="module" value="true"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry kind="src" path="src"/>
|
||||
<classpathentry kind="output" path="bin"/>
|
||||
</classpath>
|
|
@ -0,0 +1 @@
|
|||
/bin/
|
|
@ -0,0 +1,17 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<projectDescription>
|
||||
<name>Programmierung2</name>
|
||||
<comment></comment>
|
||||
<projects>
|
||||
</projects>
|
||||
<buildSpec>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.jdt.core.javabuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
</buildSpec>
|
||||
<natures>
|
||||
<nature>org.eclipse.jdt.core.javanature</nature>
|
||||
</natures>
|
||||
</projectDescription>
|
|
@ -0,0 +1,2 @@
|
|||
eclipse.preferences.version=1
|
||||
encoding/<project>=UTF-8
|
|
@ -0,0 +1,14 @@
|
|||
eclipse.preferences.version=1
|
||||
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
|
||||
org.eclipse.jdt.core.compiler.codegen.targetPlatform=22
|
||||
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
|
||||
org.eclipse.jdt.core.compiler.compliance=22
|
||||
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
|
||||
org.eclipse.jdt.core.compiler.debug.localVariable=generate
|
||||
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
|
||||
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
|
||||
org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled
|
||||
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
|
||||
org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=warning
|
||||
org.eclipse.jdt.core.compiler.release=enabled
|
||||
org.eclipse.jdt.core.compiler.source=22
|
|
@ -0,0 +1,8 @@
|
|||
/**
|
||||
*
|
||||
*/
|
||||
/**
|
||||
*
|
||||
*/
|
||||
module Programmierung2 {
|
||||
}
|
|
@ -0,0 +1,186 @@
|
|||
package Übungen;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Scanner;
|
||||
public class BankSystem {
|
||||
|
||||
protected String name;
|
||||
protected String vorname;
|
||||
protected String password;
|
||||
protected String email;
|
||||
protected double kontosstand;
|
||||
protected int alter;
|
||||
protected Scanner scanner;
|
||||
protected ArrayList<Double> speicher;
|
||||
protected static int nextKundenNummer; // Statische Variable für die nächste Kunden-ID
|
||||
|
||||
public BankSystem() {};
|
||||
|
||||
public BankSystem(String name, String vorname, String password , String email,int alter) {
|
||||
this.name = name;
|
||||
this.vorname = vorname;
|
||||
this.password = password;
|
||||
this.email = email;
|
||||
this.kontosstand = 0; // 0€
|
||||
this.setAlter(alter);
|
||||
this.scanner = new Scanner(System.in);
|
||||
this.speicher = new ArrayList<>();
|
||||
nextKundenNummer++;
|
||||
}
|
||||
|
||||
public void ueberweisung(BankSystem empfaenger) {
|
||||
|
||||
System.out.println("KontoStand: " + this.kontosstand + " €" + "\n" + this.getVorname() + " " + this.getName());
|
||||
|
||||
System.out.println("Geben Sie den Betrag ein: ");
|
||||
double betrag = scanner.nextDouble();
|
||||
scanner.nextLine();
|
||||
System.out.println("Geben Sie den Password ein: ");
|
||||
String password = scanner.nextLine();
|
||||
|
||||
if (checkKontoStand(betrag) && checkPassword(password)) {
|
||||
this.kontosstand -= betrag;
|
||||
speicher.add(- (betrag));
|
||||
|
||||
empfaenger.kontosstand +=betrag;
|
||||
empfaenger.speicher.add(betrag);
|
||||
System.out.println("Das wurde erfolgreich überwiesen");
|
||||
}
|
||||
|
||||
else
|
||||
System.out.println("Du hast kein genug Geld auf deinem Konto!");
|
||||
}
|
||||
|
||||
public void kontoauszug(){
|
||||
|
||||
int zähler = 3;
|
||||
System.out.print("Bitte geben Sie erst den Password ein: ");
|
||||
String password = scanner.nextLine();
|
||||
while(!checkPassword(password) && zähler > 1) {
|
||||
zähler--;//2
|
||||
System.out.println("Du hast " + zähler + " Versuche.");
|
||||
System.out.print("Bitte geben Sie erst den Password ein: ");
|
||||
password = scanner.nextLine();
|
||||
|
||||
}
|
||||
if (zähler == 1)
|
||||
System.err.println("Dein Konto wurde gespert!");
|
||||
|
||||
else {
|
||||
double auszahlung = 0;
|
||||
double einzahlung = 0;
|
||||
for (double i : speicher) {
|
||||
if (i < 0) {
|
||||
System.out.println("Ihre Auszahlung: "+ i);
|
||||
auszahlung += i;
|
||||
}
|
||||
else {
|
||||
System.out.println("Ihre Einzahlung: "+ i);
|
||||
einzahlung += i;
|
||||
}
|
||||
}
|
||||
System.out.println("Die Summe alle Auszahlungen = "+ auszahlung);
|
||||
System.out.println("Die Summe alle Einzahlungen = "+ einzahlung);
|
||||
System.out.println("Dein aktuelles Kontostand = "+ this.getKontosstand());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private boolean checkPassword (String password) {
|
||||
return this.password.equals(password);
|
||||
}
|
||||
|
||||
protected boolean checkKontoStand(double geld) {
|
||||
return geld <= this.kontosstand;
|
||||
}
|
||||
|
||||
|
||||
public void auszahlen(){
|
||||
|
||||
System.out.println("Bitte geben Sie den Betrag ein: ");
|
||||
|
||||
double auszahlen = scanner.nextDouble();
|
||||
scanner.nextLine();
|
||||
System.out.print("Bitte geben Sie den Password ein: ");
|
||||
String password = scanner.nextLine();
|
||||
if (checkPassword(password)) {
|
||||
if (checkKontoStand(auszahlen)) {
|
||||
this.kontosstand -= auszahlen;
|
||||
speicher.add(-(auszahlen));
|
||||
System.out.println("Auszahlung erfolgreich! Neuer Kontostand: " + this.kontosstand);
|
||||
|
||||
}
|
||||
|
||||
else
|
||||
System.out.println("Geld reicht nicht aus!");
|
||||
}
|
||||
|
||||
else
|
||||
System.out.println("falsches Password!");
|
||||
}
|
||||
|
||||
|
||||
|
||||
public void addGeld(double geld) {
|
||||
|
||||
this.kontosstand += geld;
|
||||
speicher.add(geld);
|
||||
System.out.println("Einzahlung erfolgreich! Neuer Kontostand: " + this.kontosstand);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "BankSystem [name=" + name + ", vorname=" + vorname + ", password=" + password + ", email=" + email
|
||||
+ ", kontosstand=" + kontosstand + ", alter=" + alter + "]";
|
||||
}
|
||||
|
||||
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 String getEmail() {
|
||||
return email;
|
||||
}
|
||||
public void setEmail(String email) {
|
||||
this.email = email;
|
||||
}
|
||||
public double getKontosstand() {
|
||||
return kontosstand;
|
||||
}
|
||||
public void setKontosstand(double kontosstand) {
|
||||
this.kontosstand = kontosstand;
|
||||
}
|
||||
|
||||
public int getAlter() {
|
||||
return alter;
|
||||
}
|
||||
|
||||
public void setAlter(int alter) {
|
||||
if (alter <= 20)
|
||||
System.out.println("Nein,du musst Kundenart kriegen!");
|
||||
else
|
||||
this.alter = alter;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,26 @@
|
|||
package Übungen;
|
||||
public class Kunden {
|
||||
|
||||
public static void main(String[] args) {
|
||||
BankSystem kunde1 = new BankSystem("Albek","Obai","12345","obay@gmail.com",25);
|
||||
|
||||
kunde1.addGeld(50000);
|
||||
System.out.println(kunde1.toString());
|
||||
|
||||
System.out.println();
|
||||
System.out.println();
|
||||
|
||||
BankSystem s1 = new SchuelerKonto("Albek","Obai","12345","obay@gmail.com",12,"Justus",9);
|
||||
s1.addGeld(120);
|
||||
|
||||
System.out.println(s1.toString());
|
||||
|
||||
|
||||
|
||||
|
||||
// KundenBank k1 = new KundenBank();
|
||||
// k1.setSpeicherKunde(kunde1);;
|
||||
// System.out.println(k1.getSpeicherKunde());
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,24 @@
|
|||
package Übungen;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class KundenBank {
|
||||
|
||||
private ArrayList<BankSystem> speicherKunde = new ArrayList<>();
|
||||
|
||||
public ArrayList<BankSystem> getSpeicherKunde() {
|
||||
return speicherKunde;
|
||||
}
|
||||
|
||||
public void setSpeicherKunde(BankSystem speicherKunde) {
|
||||
this.speicherKunde.add(speicherKunde);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "KundenBank [BankKunden=" + speicherKunde + "]";
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,60 @@
|
|||
package Übungen;
|
||||
|
||||
public class SchuelerKonto extends BankSystem {
|
||||
|
||||
private String schulename;
|
||||
private int klasse;
|
||||
|
||||
public SchuelerKonto(String name, String vorname, String password, String email, int alter, String schulename, int klasse) {
|
||||
super(name, vorname, password, email, alter);
|
||||
this.schulename = schulename;
|
||||
this.klasse = klasse;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addGeld(double geld) {
|
||||
if (this.kontosstand < 500) {
|
||||
this.kontosstand += geld;
|
||||
speicher.add(geld);
|
||||
System.out.println("Einzahlung erfolgreich! Neuer Kontostand: " + this.kontosstand);
|
||||
} else {
|
||||
System.out.println("Du kannst keine neuen Einzahlungen vornehmen.");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void ueberweisung(BankSystem empfaenger) {
|
||||
throw new UnsupportedOperationException("Überweisungen sind für Schülerkonten nicht erlaubt.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setAlter(int alter) {
|
||||
if (alter > 20)
|
||||
System.out.println("Nein, du kannst nicht die Kundenart Schueler haben!");
|
||||
else
|
||||
this.alter = alter;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "SchuelerKonto [Schulename=" + schulename + ", Klasse=" + klasse + ", name=" + name + ", vorname="
|
||||
+ vorname + ", password=" + password + ", email=" + email + ", kontosstand=" + kontosstand + ", alter="
|
||||
+ alter + "]";
|
||||
}
|
||||
|
||||
public String getSchulename() {
|
||||
return schulename;
|
||||
}
|
||||
|
||||
public void setSchulename(String schulename) {
|
||||
this.schulename = schulename;
|
||||
}
|
||||
|
||||
public int getKlasse() {
|
||||
return klasse;
|
||||
}
|
||||
|
||||
public void setKlasse(int klasse) {
|
||||
this.klasse = klasse;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,7 @@
|
|||
package Übungen;
|
||||
|
||||
public class StudentenKunden extends BankSystem {
|
||||
|
||||
|
||||
|
||||
}
|
Loading…
Reference in New Issue