commit c00bedbbe25784066394abd4e6c15018c02d3666 Author: Serhat Sarikaya <2110939@stud.hs-mannheim.de> Date: Tue Oct 4 00:30:45 2022 +0200 Initial commit diff --git a/Bank-Beispiel/.classpath b/Bank-Beispiel/.classpath new file mode 100644 index 0000000..57bca72 --- /dev/null +++ b/Bank-Beispiel/.classpath @@ -0,0 +1,10 @@ + + + + + + + + + + diff --git a/Bank-Beispiel/.gitignore b/Bank-Beispiel/.gitignore new file mode 100644 index 0000000..573316e --- /dev/null +++ b/Bank-Beispiel/.gitignore @@ -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 + diff --git a/Bank-Beispiel/.project b/Bank-Beispiel/.project new file mode 100644 index 0000000..49c2c92 --- /dev/null +++ b/Bank-Beispiel/.project @@ -0,0 +1,17 @@ + + + Bank-Beispiel + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/Bank-Beispiel/src/de/hs_mannheim/informatik/bank/Main.java b/Bank-Beispiel/src/de/hs_mannheim/informatik/bank/Main.java new file mode 100644 index 0000000..b075558 --- /dev/null +++ b/Bank-Beispiel/src/de/hs_mannheim/informatik/bank/Main.java @@ -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); + } + +} \ No newline at end of file diff --git a/Bank-Beispiel/src/de/hs_mannheim/informatik/bank/domain/Bank.java b/Bank-Beispiel/src/de/hs_mannheim/informatik/bank/domain/Bank.java new file mode 100644 index 0000000..0b66d3d --- /dev/null +++ b/Bank-Beispiel/src/de/hs_mannheim/informatik/bank/domain/Bank.java @@ -0,0 +1,26 @@ +package de.hs_mannheim.informatik.bank.domain; + +import java.util.Collection; +import java.util.HashMap; + +public class Bank { + private String name; + private HashMap 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 getKontenliste() { + return konten.values(); + } + +} diff --git a/Bank-Beispiel/src/de/hs_mannheim/informatik/bank/domain/Konto.java b/Bank-Beispiel/src/de/hs_mannheim/informatik/bank/domain/Konto.java new file mode 100644 index 0000000..654d503 --- /dev/null +++ b/Bank-Beispiel/src/de/hs_mannheim/informatik/bank/domain/Konto.java @@ -0,0 +1,24 @@ +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; + } + + public int getKontonummer() { + return nummer; + } + + @Override + public String toString() { + return "Konto [nummer=" + nummer + ", inhaber=" + inhaber + "]"; + } + +} diff --git a/Bank-Beispiel/src/de/hs_mannheim/informatik/bank/facade/Banksystem.java b/Bank-Beispiel/src/de/hs_mannheim/informatik/bank/facade/Banksystem.java new file mode 100644 index 0000000..821c2a9 --- /dev/null +++ b/Bank-Beispiel/src/de/hs_mannheim/informatik/bank/facade/Banksystem.java @@ -0,0 +1,37 @@ +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 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(); + } +} diff --git a/Bank-Beispiel/src/de/hs_mannheim/informatik/bank/ui/UI.java b/Bank-Beispiel/src/de/hs_mannheim/informatik/bank/ui/UI.java new file mode 100644 index 0000000..d6eb6e9 --- /dev/null +++ b/Bank-Beispiel/src/de/hs_mannheim/informatik/bank/ui/UI.java @@ -0,0 +1,64 @@ +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("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 9: break mainloop; + } + } + + 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() { + 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."); + } + +} diff --git a/README.md b/README.md new file mode 100644 index 0000000..2003d0a --- /dev/null +++ b/README.md @@ -0,0 +1,3 @@ +# Bank-System + +Beispielsystem für PR2 im WS22/23. \ No newline at end of file