generated from hummel/Bank-System
Initial commit
commit
b6c3ac7e40
|
@ -0,0 +1,11 @@
|
|||
<?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-17">
|
||||
<attributes>
|
||||
<attribute name="module" value="true"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry kind="src" path="src"/>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/5"/>
|
||||
<classpathentry kind="output" path="bin"/>
|
||||
</classpath>
|
|
@ -0,0 +1,183 @@
|
|||
# ---> Eclipse
|
||||
.metadata
|
||||
bin/
|
||||
tmp/
|
||||
*.tmp
|
||||
*.bak
|
||||
*.swp
|
||||
*~.nib
|
||||
local.properties
|
||||
.settings/
|
||||
.loadpath
|
||||
.recommenders
|
||||
|
||||
# External tool builders
|
||||
.externalToolBuilders/
|
||||
|
||||
# Locally stored "Eclipse launch configurations"
|
||||
*.launch
|
||||
|
||||
# PyDev specific (Python IDE for Eclipse)
|
||||
*.pydevproject
|
||||
|
||||
# CDT-specific (C/C++ Development Tooling)
|
||||
.cproject
|
||||
|
||||
# CDT- autotools
|
||||
.autotools
|
||||
|
||||
# Java annotation processor (APT)
|
||||
.factorypath
|
||||
|
||||
# PDT-specific (PHP Development Tools)
|
||||
.buildpath
|
||||
|
||||
# sbteclipse plugin
|
||||
.target
|
||||
|
||||
# Tern plugin
|
||||
.tern-project
|
||||
|
||||
# TeXlipse plugin
|
||||
.texlipse
|
||||
|
||||
# STS (Spring Tool Suite)
|
||||
.springBeans
|
||||
|
||||
# Code Recommenders
|
||||
.recommenders/
|
||||
|
||||
# Annotation Processing
|
||||
.apt_generated/
|
||||
.apt_generated_test/
|
||||
|
||||
# Scala IDE specific (Scala & Java development for Eclipse)
|
||||
.cache-main
|
||||
.scala_dependencies
|
||||
.worksheet
|
||||
|
||||
# Uncomment this line if you wish to ignore the project description file.
|
||||
# Typically, this file would be tracked if it contains build/dependency configurations:
|
||||
#.project
|
||||
|
||||
# ---> JetBrains
|
||||
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio, WebStorm and Rider
|
||||
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839
|
||||
|
||||
# User-specific stuff
|
||||
.idea/**/workspace.xml
|
||||
.idea/**/tasks.xml
|
||||
.idea/**/usage.statistics.xml
|
||||
.idea/**/dictionaries
|
||||
.idea/**/shelf
|
||||
|
||||
# AWS User-specific
|
||||
.idea/**/aws.xml
|
||||
|
||||
# Generated files
|
||||
.idea/**/contentModel.xml
|
||||
|
||||
# Sensitive or high-churn files
|
||||
.idea/**/dataSources/
|
||||
.idea/**/dataSources.ids
|
||||
.idea/**/dataSources.local.xml
|
||||
.idea/**/sqlDataSources.xml
|
||||
.idea/**/dynamic.xml
|
||||
.idea/**/uiDesigner.xml
|
||||
.idea/**/dbnavigator.xml
|
||||
|
||||
# Gradle
|
||||
.idea/**/gradle.xml
|
||||
.idea/**/libraries
|
||||
|
||||
# Gradle and Maven with auto-import
|
||||
# When using Gradle or Maven with auto-import, you should exclude module files,
|
||||
# since they will be recreated, and may cause churn. Uncomment if using
|
||||
# auto-import.
|
||||
# .idea/artifacts
|
||||
# .idea/compiler.xml
|
||||
# .idea/jarRepositories.xml
|
||||
# .idea/modules.xml
|
||||
# .idea/*.iml
|
||||
# .idea/modules
|
||||
# *.iml
|
||||
# *.ipr
|
||||
|
||||
# CMake
|
||||
cmake-build-*/
|
||||
|
||||
# Mongo Explorer plugin
|
||||
.idea/**/mongoSettings.xml
|
||||
|
||||
# File-based project format
|
||||
*.iws
|
||||
|
||||
# IntelliJ
|
||||
out/
|
||||
|
||||
# mpeltonen/sbt-idea plugin
|
||||
.idea_modules/
|
||||
|
||||
# JIRA plugin
|
||||
atlassian-ide-plugin.xml
|
||||
|
||||
# Cursive Clojure plugin
|
||||
.idea/replstate.xml
|
||||
|
||||
# SonarLint plugin
|
||||
.idea/sonarlint/
|
||||
|
||||
# Crashlytics plugin (for Android Studio and IntelliJ)
|
||||
com_crashlytics_export_strings.xml
|
||||
crashlytics.properties
|
||||
crashlytics-build.properties
|
||||
fabric.properties
|
||||
|
||||
# Editor-based Rest Client
|
||||
.idea/httpRequests
|
||||
|
||||
# Android studio 3.1+ serialized cache file
|
||||
.idea/caches/build_file_checksums.ser
|
||||
|
||||
# ---> Java
|
||||
# Compiled class file
|
||||
*.class
|
||||
|
||||
# Log file
|
||||
*.log
|
||||
|
||||
# BlueJ files
|
||||
*.ctxt
|
||||
|
||||
# Mobile Tools for Java (J2ME)
|
||||
.mtj.tmp/
|
||||
|
||||
# Package Files #
|
||||
*.jar
|
||||
*.war
|
||||
*.nar
|
||||
*.ear
|
||||
*.zip
|
||||
*.tar.gz
|
||||
*.rar
|
||||
|
||||
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
|
||||
hs_err_pid*
|
||||
replay_pid*
|
||||
|
||||
# ---> VisualStudioCode
|
||||
.vscode/*
|
||||
!.vscode/settings.json
|
||||
!.vscode/tasks.json
|
||||
!.vscode/launch.json
|
||||
!.vscode/extensions.json
|
||||
!.vscode/*.code-snippets
|
||||
|
||||
# Local History for Visual Studio Code
|
||||
.history/
|
||||
|
||||
# Built Visual Studio Code Extensions
|
||||
*.vsix
|
||||
|
||||
/bank.ser
|
||||
/zähler.ser
|
|
@ -0,0 +1,17 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<projectDescription>
|
||||
<name>Bank-Beispiel</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,13 @@
|
|||
package de.hs_mannheim.informatik.bank;
|
||||
|
||||
import de.hs_mannheim.informatik.bank.facade.Banksystem;
|
||||
import de.hs_mannheim.informatik.bank.ui.UI;
|
||||
|
||||
public class Main {
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
Banksystem bs = new Banksystem("Spaßkasse Mannheim");
|
||||
UI ui = new UI(bs);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,42 @@
|
|||
package de.hs_mannheim.informatik.bank.domain;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
|
||||
public class Bank implements Serializable {
|
||||
private String name;
|
||||
private HashMap<Integer, Konto> konten = new HashMap<>();
|
||||
private int kontozähler;
|
||||
|
||||
public Bank(String name) {
|
||||
this.name = name;
|
||||
this.kontozähler = -1;
|
||||
}
|
||||
|
||||
public int addKonto(String name, int auswahl) {
|
||||
Konto k;
|
||||
|
||||
if (auswahl == 1)
|
||||
k = new Konto(name, ++kontozähler);
|
||||
else
|
||||
k = new Girokonto(name, ++kontozähler);
|
||||
|
||||
konten.put(k.getKontonummer(), k);
|
||||
|
||||
return k.getKontonummer();
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public Collection<Konto> getKontenliste() {
|
||||
return konten.values();
|
||||
}
|
||||
|
||||
public Konto findeKonto(int kontonummer) {
|
||||
return konten.get(kontonummer);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,27 @@
|
|||
package de.hs_mannheim.informatik.bank.domain;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
public class Girokonto extends Konto implements Serializable {
|
||||
|
||||
public Girokonto(String inhaber, int kontozähler) {
|
||||
super(inhaber, kontozähler);
|
||||
}
|
||||
|
||||
public boolean überweise(Girokonto ziel, long betrag, String zweck) {
|
||||
if (super.getKontostand() - betrag >= 0) {
|
||||
this.auszahlen(betrag, zweck, "Überweisungsausgang", super.getInhaber());
|
||||
ziel.einzahlen(betrag, zweck, "Überweisungseingang", super.getInhaber());
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Giro-" + super.toString();
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,66 @@
|
|||
package de.hs_mannheim.informatik.bank.domain;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class Konto implements Serializable {
|
||||
private int nummer;
|
||||
private long stand = 0;
|
||||
private String inhaber;
|
||||
|
||||
private ArrayList<Kontobewegung> kontobewegungen;
|
||||
|
||||
public Konto(String inhaber, int kontozähler) {
|
||||
nummer = 1000 + kontozähler;
|
||||
this.inhaber = inhaber;
|
||||
|
||||
this.kontobewegungen = new ArrayList<>();
|
||||
}
|
||||
|
||||
public int getKontonummer() {
|
||||
return nummer;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Konto [nummer=" + nummer + ", inhaber=" + inhaber + "]";
|
||||
}
|
||||
|
||||
public String getInhaber() {
|
||||
return inhaber;
|
||||
}
|
||||
|
||||
public long getKontostand() {
|
||||
return stand;
|
||||
}
|
||||
|
||||
public void einzahlen(long betrag, String zweck, String art, String auftraggeber) {
|
||||
stand += betrag;
|
||||
|
||||
kontobewegungen.add(new Kontobewegung(betrag, zweck, art, auftraggeber));
|
||||
}
|
||||
|
||||
public boolean auszahlen(long betrag, String zweck, String art, String auftraggeber) {
|
||||
if (stand - betrag >= 0) {
|
||||
stand -= betrag;
|
||||
|
||||
kontobewegungen.add(new Kontobewegung(betrag * -1, zweck, art, auftraggeber));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public String[] getKontobewegungen() {
|
||||
String[] auflistung = new String[kontobewegungen.size()];
|
||||
|
||||
int i = 0;
|
||||
for (Kontobewegung kb : kontobewegungen) {
|
||||
auflistung[i++] = kb.toString();
|
||||
}
|
||||
|
||||
return auflistung;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,35 @@
|
|||
package de.hs_mannheim.informatik.bank.domain;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
class KontoTest {
|
||||
|
||||
@Test
|
||||
void testKontoBasics() {
|
||||
Konto k = new Konto("Müller", 0);
|
||||
assertEquals("Müller", k.getInhaber());
|
||||
assertEquals(1000, k.getKontonummer());
|
||||
assertEquals(0, k.getKontostand());
|
||||
}
|
||||
|
||||
@Test
|
||||
void testKontoEinUndAuszahlung() {
|
||||
Konto k = new Konto("Müller", 0);
|
||||
Konto k2 = new Konto("Mayer", 1);
|
||||
|
||||
assertEquals("Mayer", k2.getInhaber());
|
||||
assertNotEquals(k.getKontonummer(), k2.getKontonummer());
|
||||
|
||||
k2.einzahlen(100, "Test", "Einzahlung", "JUnit");
|
||||
assertEquals(100, k2.getKontostand());
|
||||
|
||||
assertTrue(k2.auszahlen(50, "Test", "Auszahlung", "JUnit"));
|
||||
assertEquals(50, k2.getKontostand());
|
||||
|
||||
assertFalse(k2.auszahlen(500, "Test", "Auszahlung", "JUnit"));
|
||||
assertEquals(50, k2.getKontostand());
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,28 @@
|
|||
package de.hs_mannheim.informatik.bank.domain;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
public class Kontobewegung implements Serializable {
|
||||
private long betrag;
|
||||
private Date datum;
|
||||
private String betreff;
|
||||
private String art;
|
||||
private String auftraggeber;
|
||||
|
||||
public Kontobewegung(long betrag, String betreff, String art, String auftraggeber) {
|
||||
this.betrag = betrag;
|
||||
this.betreff = betreff;
|
||||
this.art = art;
|
||||
this.auftraggeber = auftraggeber;
|
||||
|
||||
this.datum = new Date();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Kontobewegung [betrag=" + betrag + ", datum=" + datum + ", betreff=" + betreff + ", art=" + art
|
||||
+ ", auftraggeber=" + auftraggeber + "]";
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,84 @@
|
|||
package de.hs_mannheim.informatik.bank.facade;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
import de.hs_mannheim.informatik.bank.domain.Bank;
|
||||
import de.hs_mannheim.informatik.bank.domain.Girokonto;
|
||||
import de.hs_mannheim.informatik.bank.domain.Konto;
|
||||
import de.hs_mannheim.informatik.bank.infrastructure.Persistenz;
|
||||
|
||||
public class Banksystem {
|
||||
private Bank bank;
|
||||
|
||||
public Banksystem(String bankname) throws Exception {
|
||||
if (Persistenz.sindDatenGespeichert(bankname))
|
||||
this.bank = (Bank) Persistenz.ladeBankDaten(bankname);
|
||||
else
|
||||
this.bank = new Bank(bankname);
|
||||
}
|
||||
|
||||
public int kontoAnlegen(String name, int auswahl) throws Exception {
|
||||
int kontonummer = bank.addKonto(name, auswahl);
|
||||
|
||||
Persistenz.speichereBankDaten(this.bank, bank.getName());
|
||||
|
||||
return kontonummer;
|
||||
}
|
||||
|
||||
public String[] getKontenliste() {
|
||||
Collection<Konto> konten = bank.getKontenliste();
|
||||
String[] liste = new String[konten.size()];
|
||||
|
||||
int i = 0;
|
||||
for (Konto k : konten) {
|
||||
liste[i++] = k.toString();
|
||||
}
|
||||
|
||||
return liste;
|
||||
}
|
||||
|
||||
public String getBankname() {
|
||||
return bank.getName();
|
||||
}
|
||||
|
||||
public long geldEinzahlen(int kontonummer, long betrag) throws Exception {
|
||||
Konto konto = bank.findeKonto(kontonummer);
|
||||
konto.einzahlen(betrag, "Einzahlung am Schalter", "Einzahlung", konto.getInhaber());
|
||||
|
||||
Persistenz.speichereBankDaten(this.bank, bank.getName());
|
||||
|
||||
return konto.getKontostand();
|
||||
}
|
||||
|
||||
public boolean geldAuszahlen(int kontonummer, long betrag) throws Exception {
|
||||
Konto konto = bank.findeKonto(kontonummer);
|
||||
|
||||
Persistenz.speichereBankDaten(this.bank, bank.getName());
|
||||
|
||||
return konto.auszahlen(betrag, "Auszahlung am Schalter", "Auszahlung", konto.getInhaber());
|
||||
}
|
||||
|
||||
public String[] erstelleKontoauszug(int kontonummer) {
|
||||
Konto konto = bank.findeKonto(kontonummer);
|
||||
|
||||
return konto.getKontobewegungen();
|
||||
}
|
||||
|
||||
public boolean überweisungBeauftragen(int startkonto, int zielkonto, long betrag, String verwendungszweck) {
|
||||
Konto start = bank.findeKonto(startkonto);
|
||||
Konto ziel = bank.findeKonto(zielkonto);
|
||||
|
||||
if (start instanceof Girokonto && ziel instanceof Girokonto) {
|
||||
return ((Girokonto)start).überweise((Girokonto)ziel, betrag, verwendungszweck);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public long getKontostand(int kontonummer) {
|
||||
Konto konto = bank.findeKonto(kontonummer);
|
||||
|
||||
return konto.getKontostand();
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,19 @@
|
|||
package de.hs_mannheim.informatik.bank.facade;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
class SystemTest {
|
||||
|
||||
@Test
|
||||
void smokeTest() throws Exception {
|
||||
Banksystem bs = new Banksystem("Testsystem");
|
||||
|
||||
assertNotNull(bs);
|
||||
assertEquals(0, bs.getKontenliste().length);
|
||||
assertEquals("Testsystem", bs.getBankname());
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,30 @@
|
|||
package de.hs_mannheim.informatik.bank.infrastructure;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.ObjectInputStream;
|
||||
import java.io.ObjectOutputStream;
|
||||
|
||||
public class Persistenz {
|
||||
private static final String BANK_DATEI = "-bank-data.ser";
|
||||
|
||||
public static boolean sindDatenGespeichert(String name) {
|
||||
return new File(name + BANK_DATEI).exists();
|
||||
}
|
||||
|
||||
public static void speichereBankDaten(Object bank, String name) throws Exception {
|
||||
ObjectOutputStream oos = new ObjectOutputStream(new FileOutputStream(name + BANK_DATEI));
|
||||
oos.writeObject(bank);
|
||||
oos.close();
|
||||
}
|
||||
|
||||
public static Object ladeBankDaten(String name) throws Exception {
|
||||
ObjectInputStream ois = new ObjectInputStream(new FileInputStream(name + BANK_DATEI));
|
||||
Object bank = ois.readObject();
|
||||
ois.close();
|
||||
|
||||
return bank;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,149 @@
|
|||
package de.hs_mannheim.informatik.bank.ui;
|
||||
|
||||
import java.util.Scanner;
|
||||
|
||||
import de.hs_mannheim.informatik.bank.facade.Banksystem;
|
||||
|
||||
public class UI {
|
||||
private Banksystem bs;
|
||||
Scanner sc = new Scanner(System.in);
|
||||
|
||||
public UI(Banksystem bs) {
|
||||
this.bs = bs;
|
||||
hauptmenü();
|
||||
}
|
||||
|
||||
private void hauptmenü() {
|
||||
System.out.println("Willkommen bei der " + bs.getBankname() + "!");
|
||||
|
||||
mainloop:
|
||||
while (true) {
|
||||
System.out.println();
|
||||
System.out.println("--------");
|
||||
System.out.println("Hauptmenü");
|
||||
System.out.println("1 -> Konten anzeigen");
|
||||
System.out.println("2 -> Konto anlegen");
|
||||
System.out.println("3 -> Geld einzahlen");
|
||||
System.out.println("4 -> Geld auszahlen");
|
||||
System.out.println("5 -> Kontoauszug drucken");
|
||||
System.out.println("6 -> Überweisung beauftragen");
|
||||
|
||||
System.out.println("9 -> Beenden");
|
||||
System.out.println();
|
||||
|
||||
System.out.print("> ");
|
||||
int input = Integer.parseInt(sc.nextLine());
|
||||
System.out.println();
|
||||
|
||||
try {
|
||||
switch(input) {
|
||||
case 1: kontenAnzeigen(); break;
|
||||
case 2:
|
||||
kontoAnlegen();
|
||||
break;
|
||||
case 3: geldEinzahlen(); break;
|
||||
case 4: geldAuszahlen(); break;
|
||||
case 5: kontoauszugDrucken(); break;
|
||||
case 6: überweisungBeauftragen(); break;
|
||||
case 9: break mainloop;
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
System.err.println(e.getLocalizedMessage());
|
||||
}
|
||||
System.out.println();
|
||||
}
|
||||
|
||||
System.out.println("Auf Wiedersehen!");
|
||||
|
||||
} // hauptmenü
|
||||
|
||||
private void kontenAnzeigen() {
|
||||
String[] konten = bs.getKontenliste();
|
||||
if (konten.length > 0) {
|
||||
System.out.println("Folgende Konten sind aktuell verfügbar:");
|
||||
for (String s : konten) {
|
||||
System.out.println(s);
|
||||
}
|
||||
} else {
|
||||
System.out.println("Bisher keine Konten angelegt.");
|
||||
}
|
||||
}
|
||||
|
||||
private void kontoAnlegen() throws Exception {
|
||||
System.out.println("Bitte den Namen des Kontoinhabers angeben: ");
|
||||
String name = sc.nextLine();
|
||||
|
||||
System.out.println("Möchten Sie ein Sparkonto (1) oder ein Girokonto (2) anlegen?");
|
||||
int auswahl = Integer.parseInt(sc.nextLine());
|
||||
|
||||
int kontonummer = bs.kontoAnlegen(name, auswahl);
|
||||
System.out.println("Konto mit der Nummer " + kontonummer + " neu angelegt.");
|
||||
}
|
||||
|
||||
private void geldEinzahlen() throws Exception {
|
||||
System.out.println("Geld einzahlen");
|
||||
System.out.print("Bitte die gewünschte Kontonummer eingeben: ");
|
||||
int kontonummer = Integer.parseInt(sc.nextLine());
|
||||
|
||||
// optional prüfen, ob Konto existiert
|
||||
|
||||
System.out.print("Bitte den gewünschten Betrag eingeben: ");
|
||||
double betrag = Double.parseDouble(sc.nextLine());
|
||||
|
||||
long neuerKontostand = bs.geldEinzahlen(kontonummer, (long)betrag * 100);
|
||||
|
||||
System.out.printf("Einzahlung erfolgreich, neuer Kontostand = %.2f Euro", (neuerKontostand / 100.0));
|
||||
}
|
||||
|
||||
private void geldAuszahlen() throws Exception {
|
||||
System.out.println("Geld auszahlen");
|
||||
System.out.print("Bitte die gewünschte Kontonummer eingeben: ");
|
||||
int kontonummer = Integer.parseInt(sc.nextLine());
|
||||
|
||||
System.out.print("Bitte den gewünschten Betrag eingeben: ");
|
||||
double betrag = Double.parseDouble(sc.nextLine());
|
||||
|
||||
boolean erfolgreich = bs.geldAuszahlen(kontonummer, (long)betrag * 100);
|
||||
|
||||
System.out.printf("Auszahlung" + ((!erfolgreich)? " nicht" : "" )+ " erfolgreich. ");
|
||||
System.out.printf("Neuer Kontostand = %.2f Euro.", (bs.getKontostand(kontonummer) / 100.0));
|
||||
}
|
||||
|
||||
private void kontoauszugDrucken() {
|
||||
System.out.print("Bitte die gewünschte Kontonummer für den Auszug eingeben: ");
|
||||
int kontonummer = Integer.parseInt(sc.nextLine());
|
||||
|
||||
System.out.println();
|
||||
|
||||
// in echt auf einem Drucker
|
||||
System.out.println("Auszug für Konto " + kontonummer);
|
||||
String[] kontobewegungen = bs.erstelleKontoauszug(kontonummer);
|
||||
|
||||
if (kontobewegungen.length > 0)
|
||||
for (String kb : kontobewegungen) {
|
||||
System.out.println(kb);
|
||||
}
|
||||
else
|
||||
System.out.println("Noch keine Kontobewegungen.");
|
||||
}
|
||||
|
||||
private void überweisungBeauftragen() {
|
||||
System.out.print("Bitte die Kontonummer des Ausgangskontos der Überweisung eingeben: ");
|
||||
int startkonto = Integer.parseInt(sc.nextLine());
|
||||
|
||||
System.out.print("Bitte die Kontonummmer für das Zielkonto der Überweisung eingeben: ");
|
||||
int zielkonto = Integer.parseInt(sc.nextLine());
|
||||
|
||||
System.out.print("Bitte den gewünschten Überweisungsbetrag eingeben: ");
|
||||
double betrag = Double.parseDouble(sc.nextLine());
|
||||
|
||||
System.out.print("Bitte den Verwendungszweck eingeben: ");
|
||||
String verwendungszweck = sc.nextLine();
|
||||
|
||||
boolean erfolgreich = bs.überweisungBeauftragen(startkonto, zielkonto, (long)(betrag * 100), verwendungszweck);
|
||||
|
||||
System.out.println("Überweisung" + ( (!erfolgreich) ? " nicht" : "") + " erfolgreich ausgeführt.");
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue