first commit
commit
d6c2d7ea3c
|
@ -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-16">
|
||||
<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,181 @@
|
|||
# ---> 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
|
||||
|
|
@ -0,0 +1,28 @@
|
|||
<?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>
|
||||
<filteredResources>
|
||||
<filter>
|
||||
<id>1664805428804</id>
|
||||
<name></name>
|
||||
<type>30</type>
|
||||
<matcher>
|
||||
<id>org.eclipse.core.resources.regexFilterMatcher</id>
|
||||
<arguments>node_modules|\.git|__CREATED_BY_JAVA_LANGUAGE_SERVER__</arguments>
|
||||
</matcher>
|
||||
</filter>
|
||||
</filteredResources>
|
||||
</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) {
|
||||
Banksystem bs = new Banksystem("Spaßkasse Mannheim");
|
||||
UI ui = new UI(bs);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,54 @@
|
|||
package de.hs_mannheim.informatik.bank.domain;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
|
||||
public class Bank {
|
||||
private Konto k;
|
||||
private String name;
|
||||
private HashMap<Integer, Konto> konten = new HashMap<>();
|
||||
|
||||
public Bank(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public void addKonto(Konto k) {
|
||||
konten.put(k.getKontonummer(), k);
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public Collection<Konto> getKontenliste() {
|
||||
return konten.values();
|
||||
}
|
||||
|
||||
public long geldWirdInDerBankAngelegt(int kontoNummer, long geldBetrag) {
|
||||
k = getKonto(kontoNummer);
|
||||
k.setStand(k.getStand()+geldBetrag);
|
||||
return k.getStand();
|
||||
}
|
||||
|
||||
public long kontoStandFinden(int kontNumToGetKontoStand) {
|
||||
k = getKonto(kontNumToGetKontoStand);
|
||||
return k.getStand();
|
||||
}
|
||||
|
||||
public String geldAbhebenBank(int kontoNummer, long geldAbgehoben) {
|
||||
k = getKonto(kontoNummer);
|
||||
|
||||
if(k.getStand() < geldAbgehoben) {
|
||||
return "Sie haben zu wenig Geld auf ihrem Konto";
|
||||
}
|
||||
|
||||
k.setStand(k.getStand()-geldAbgehoben);
|
||||
return "Sie haben" + geldAbgehoben + "Euro abgehoben";
|
||||
}
|
||||
|
||||
private Konto getKonto(int Kontonummer) {
|
||||
k = konten.get(Kontonummer);
|
||||
return k;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,33 @@
|
|||
package de.hs_mannheim.informatik.bank.domain;
|
||||
|
||||
public class Konto {
|
||||
private static int kontozähler = 0;
|
||||
|
||||
private int nummer;
|
||||
private long stand = 0;
|
||||
private String inhaber;
|
||||
|
||||
public Konto(String inhaber) {
|
||||
nummer = 1000 + kontozähler++;
|
||||
this.inhaber = inhaber;
|
||||
getStand();
|
||||
}
|
||||
|
||||
public int getKontonummer() {
|
||||
return nummer;
|
||||
}
|
||||
|
||||
public long getStand(){
|
||||
return stand;
|
||||
}
|
||||
|
||||
public void setStand(long stand){
|
||||
this.stand = stand;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Konto [nummer=" + nummer + ", inhaber=" + inhaber + ", Kontostand=" + stand + "]";
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,35 @@
|
|||
package de.hs_mannheim.informatik.bank.facade;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import de.hs_mannheim.informatik.bank.domain.Bank;
|
||||
import de.hs_mannheim.informatik.bank.domain.Konto;
|
||||
|
||||
public class BankSystemTest {
|
||||
|
||||
|
||||
@Test
|
||||
public void testGeldEinzahlen(){
|
||||
Bank bs = new Bank("Sparkasse");
|
||||
Konto k = new Konto("Bob");
|
||||
Konto k1 = new Konto("John");
|
||||
bs.addKonto(k);
|
||||
bs.addKonto(k1);
|
||||
long einzahlenTest = bs.geldWirdInDerBankAngelegt(1000, 200);
|
||||
long k1EinzahlenTest = bs.geldWirdInDerBankAngelegt(1001, 100);
|
||||
long testSumme = 200;
|
||||
long testSummeZwei = 100;
|
||||
assertEquals(einzahlenTest, testSumme);
|
||||
assertEquals(k1EinzahlenTest, testSummeZwei);
|
||||
}
|
||||
|
||||
|
||||
/* public void testGeldEinzahlenAPI(){
|
||||
bs.addKonto(k1);
|
||||
float geldSehen = bSys.geldEinzahlen(1000, 100);
|
||||
float testLookMoney = 100;
|
||||
assertEquals(geldSehen, testLookMoney);
|
||||
}*/
|
||||
}
|
|
@ -0,0 +1,52 @@
|
|||
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.Konto;
|
||||
|
||||
public class Banksystem {
|
||||
private Bank bank;
|
||||
|
||||
public Banksystem(String bankname) {
|
||||
this.bank = new Bank(bankname);
|
||||
}
|
||||
|
||||
public int kontoAnlegen(String name) {
|
||||
Konto k = new Konto(name);
|
||||
bank.addKonto(k);
|
||||
|
||||
return k.getKontonummer();
|
||||
}
|
||||
|
||||
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 geldBetrag) {
|
||||
long geldEinbezahlt = bank.geldWirdInDerBankAngelegt(kontoNummer,geldBetrag);
|
||||
return geldEinbezahlt;
|
||||
}
|
||||
|
||||
public long sucheNachKontoStand(int kontNumToGetKontoStand) {
|
||||
long aktuellerKontostand = bank.kontoStandFinden(kontNumToGetKontoStand);
|
||||
return aktuellerKontostand;
|
||||
}
|
||||
|
||||
public String geldAbheben(int kontoNummer, long geldAbheben) {
|
||||
String geldAbgehoben = bank.geldAbhebenBank(kontoNummer, geldAbheben);
|
||||
return geldAbgehoben;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,95 @@
|
|||
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;
|
||||
hauptmenue();
|
||||
}
|
||||
|
||||
private void hauptmenue() {
|
||||
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 -> Geldbetrag einzahlen");
|
||||
System.out.println("4 -> Konto abfragen");
|
||||
System.out.println("5 -> Geld abheben");
|
||||
System.out.println("9 -> Beenden");
|
||||
System.out.println();
|
||||
|
||||
System.out.print("> ");
|
||||
int input = Integer.parseInt(sc.nextLine());
|
||||
System.out.println();
|
||||
|
||||
switch(input) {
|
||||
case 1: kontenAnzeigen(); break;
|
||||
case 2: kontoAnlegen(); break;
|
||||
case 3: geldbetragEinzahlen(); break;
|
||||
case 4: kontoAbfragen(); break;
|
||||
case 5: geldAbheben(); break;
|
||||
case 9: break mainloop;
|
||||
}
|
||||
}
|
||||
|
||||
System.out.println("Auf Wiedersehen!");
|
||||
|
||||
} // hauptmenü
|
||||
|
||||
private void geldAbheben() {
|
||||
System.out.println("Geben Sie ihre Kontonummer ein");
|
||||
int kontoNummer = Integer.parseInt(sc.nextLine());
|
||||
System.out.println("Bitte geben sie denn Betrag ein denn sie abheben wollen");
|
||||
long geldAbheben = Long.parseLong(sc.nextLine());
|
||||
String abgehobenString = bs.geldAbheben(kontoNummer,geldAbheben);
|
||||
System.out.println(abgehobenString);
|
||||
}
|
||||
|
||||
private void kontoAbfragen() {
|
||||
System.out.println("Geben sie ihr Kontonummer ein um ihren Kontostand zu sehen");
|
||||
int kontNumToGetKontoStand = Integer.parseInt(sc.nextLine());
|
||||
long aktuellerKontostand =bs.sucheNachKontoStand(kontNumToGetKontoStand);
|
||||
System.out.println("Ihr aktueller Kontostand ist: " + aktuellerKontostand);
|
||||
}
|
||||
|
||||
private void geldbetragEinzahlen() {
|
||||
System.out.println("Geben Sie ihre Kontonummer ein");
|
||||
int kontoNummer = Integer.parseInt(sc.nextLine());
|
||||
System.out.println("Bitte geben sie denn Betrag ein denn sie einzahlen möschten");
|
||||
long geldBetrag = Long.parseLong(sc.nextLine());
|
||||
long neuerGeldBetrag = bs.geldEinzahlen(kontoNummer,geldBetrag);
|
||||
System.out.println("Ihr neuer Betrag ist: " + neuerGeldBetrag);
|
||||
}
|
||||
|
||||
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() {
|
||||
System.out.println("Bitte den Namen des Kontoinhabers angeben: ");
|
||||
String name = sc.nextLine();
|
||||
|
||||
int kontonummer = bs.kontoAnlegen(name);
|
||||
System.out.println("Konto mit der Nummer " + kontonummer + " neu angelegt.");
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue