Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.CedricKk.Java.GUI;
- import java.io.*;
- import java.lang.Integer;
- import java.io.BufferedReader;
- import java.io.File;
- import java.io.FileNotFoundException;
- import java.io.FileReader;
- import java.io.IOException;
- import java.io.Reader;
- import java.util.LinkedList;
- /*******************************************
- * Kontomannager
- * Version 3.3
- * Author: Cedric Kienzler
- * all rights reserved
- * if you have any questions:
- * cedrickienzler1@googlemail.com
- ********************************************/
- public class Konto {
- public static boolean first_run = true;
- public static double version = 3.3;
- public static double guthaben = 0 , einzahlen = 0 , auszahlen = 0;
- public static int ID = 0, Kontonr = 0 , blz = 0;
- public static String Geldinstitut , Kontoinhaber;
- private static BufferedReader br = null;
- public static String fehler , auswählen , temp1 = "abheben" , temp2 = "einzahlen" , temp3 = "anzeigen" , temp4 = "speichern";
- public static String temp , dateiName, save1 , save2 , save3, save4 , save5 , save6 , save7, save8;
- public static void Varaiblen2String() {
- save1 = Double.toString(guthaben);
- save2 = Double.toString(einzahlen);
- save3 = Double.toString(auszahlen);
- save4 = Integer.toString(ID);
- save5 = Integer.toString(Kontonr);
- save6 = Integer.toString(blz);
- save7 = Geldinstitut;
- save8 = Kontoinhaber;
- }
- public static void welcome() {
- int y = 0;
- int z = 200000;
- System.out.println ("\n \n \n \n \n \n");
- System.out.println (" Kontomannager ");
- System.out.println ();
- System.out.println ("* Copyright (c) 2010 by Cedric Kienzler");
- System.out.println ("* Version: " + version);
- System.out.println ("* all rights reserved");
- System.out.println ("* any questions?");
- System.out.println ("* ask me! at:");
- System.out.println ("* cedrickienzler1@googlemail.com");
- while (y == z) {
- y++;
- }
- System.out.println ("\n \n \n \n \n \n");
- System.out.println (" Kontomannager ");
- System.out.println ();
- System.out.println ("* Copyright (c) 2010 by Cedric Kienzler");
- System.out.println ("* Version 3.0");
- System.out.println ("* all rights reserved");
- System.out.println ("* any questions?");
- System.out.println ("* ask me! at:");
- System.out.println ("* cedrickienzler1@googlemail.com");
- }
- public static void error() {
- System.err.println("Fehler:" + fehler);
- }
- public static void reader() throws IOException {
- br = new BufferedReader(new InputStreamReader( System.in ) );
- }
- public static void festlegung_Konto() {
- try {
- ID++;
- reader();
- System.out.println ("\n \n \n \n \n");
- System.out.println("Bitte geben sie den Kontoinhaber ein:");
- Kontoinhaber = br.readLine();
- System.out.println ("\n \n");
- System.out.println("Bitte geben sie das Geld Instutut ein:");
- Geldinstitut = br.readLine();
- System.out.println ("\n \n ");
- System.out.println("Bitte geben sie ihre Kontonummer an:");
- String userInput = br.readLine();
- Kontonr = Integer.parseInt(userInput);
- System.out.println ("\n \n ");
- System.out.println("Bitte geben sie die Bankleitzahl an:");
- userInput = br.readLine();
- blz = Integer.parseInt(userInput);
- System.out.println ("\n \n ");
- System.out.println("Bitte geben sie ihren aktuellen Kontostand ein:");
- userInput = br.readLine();
- guthaben = Integer.parseInt(userInput);
- }
- catch (IOException e) {
- //e.printStackTrace();
- System.out.println ("\n \n");
- fehler = "Fehler beim einlesen der Eingaben";
- error();
- }
- }
- public static void ausgabe_Auswählen() {
- System.out.println("Wenn sie einen Betrag einzahlen möchten, dan tippen sie bitte \n >>einzahlen<<");
- System.out.println("Wenn sie einen Betrag auszahlen möchten, dann tippen sie bitte \n >>abheben<<");
- System.out.println ("Um alle informationen über ihn Konto anzuzeigen, tippen sie bitte \n >>anzeigen<<");
- System.out.println ("Wenn sie ihre eingaben speichern wollen, tippen sie bitte \n speichern");
- try {
- reader();
- auswählen = br.readLine();
- }
- catch (IOException e) {
- e.printStackTrace();
- fehler = "Fehler beim einlesen ihrer Tastatureingabe";
- error();
- }
- }
- public static double abheben() {
- System.out.println ("\n \n ");
- try {
- reader();
- System.out.println("Bitte geben sie den auszuzahlenden Betrag ein:");
- String userInput = br.readLine();
- auszahlen = Double.parseDouble(userInput);
- guthaben = guthaben - auszahlen;
- }
- catch (IOException e) {
- e.printStackTrace();
- fehler = "Fehler bei der eingabe des auszuzahlenen Betrages!";
- error();
- }
- return auszahlen;
- }
- public static double einzahlen() {
- guthaben = guthaben + einzahlen;
- return einzahlen;
- }
- public static void ausgabe_Kontoinfo() {
- System.out.println ("ID:" + ID);
- System.out.println ("Kontoinhaber: " + Kontoinhaber);
- System.out.println ("Bankleitzahl / Geldinstitut: " + blz + " / " + Geldinstitut );
- System.out.println ("Kontonummer: " + Kontonr);
- System.out.println (" \n Aktuelles Guthaben:" + guthaben);
- System.out.println (" \n Letzte Transaktionen: ");
- System.out.println ("Letze Einzahlung erfolgte in einer höhe von: "+ einzahlen + "Euro");
- System.out.println ("Letze auszahlung erfolgte in einer höhe von: " + auszahlen + "Euro");
- }
- public static void speichern() {
- Varaiblen2String();
- try {
- System.out.println ("Geben sie bitte den Dateinamen ein, der auf '.txt' endet \n zum Beispiel: 'test.txt' ");
- temp = br.readLine();
- dateiName = temp;
- }
- catch (IOException e) {
- System.out.println ("Fehler!");
- }
- FileOutputStream schreibeStrom = null;
- try {
- schreibeStrom = new FileOutputStream(dateiName);
- } catch (FileNotFoundException e) {
- e.printStackTrace();
- }
- for (int i1=0; i1 < save1.length(); i1++){
- try {
- schreibeStrom.write((byte)save1.charAt(i1));
- } catch (IOException e) {
- e.printStackTrace();
- }
- }
- for (int i2=0; i2 < save2.length(); i2++){
- try {
- schreibeStrom.write((byte)save2.charAt(i2));
- } catch (IOException e) {
- e.printStackTrace();
- }
- }
- for (int i3=0; i3 < save3.length(); i3++){
- try {
- schreibeStrom.write((byte)save3.charAt(i3));
- } catch (IOException e) {
- e.printStackTrace();
- }
- }
- for (int i4=0; i4 < save4.length(); i4++){
- try {
- schreibeStrom.write((byte)save4.charAt(i4));
- } catch (IOException e) {
- e.printStackTrace();
- }
- }
- for (int i5=0; i5 < save5.length(); i5++){
- try {
- schreibeStrom.write((byte)save5.charAt(i5));
- } catch (IOException e) {
- e.printStackTrace();
- }
- }
- for (int i6=0; i6 < save6.length(); i6++){
- try {
- schreibeStrom.write((byte)save6.charAt(i6));
- } catch (IOException e) {
- e.printStackTrace();
- }
- }
- for (int i7=0; i7 < save7.length(); i7++){
- try {
- schreibeStrom.write((byte)save7.charAt(i7));
- } catch (IOException e) {
- e.printStackTrace();
- }
- }
- for (int i8=0; i8 < save8.length(); i8++){
- try {
- schreibeStrom.write((byte)save8.charAt(i8));
- } catch (IOException e) {
- e.printStackTrace();
- }
- }
- try {
- schreibeStrom.close();
- } catch (IOException e) {
- e.printStackTrace();
- }
- System.out.println("Dateien erfolgreich gespeichert.");
- }
- public static void main (String[] args) {
- welcome();
- festlegung_Konto();
- while (true) {
- System.out.println ("\n \n \n \n \n \n");
- ausgabe_Auswählen();
- if (auswählen.equals(temp1)) {
- abheben();
- }
- else {
- if (auswählen.equals(temp2)) {
- einzahlen();
- }
- else {
- if (auswählen.equals(temp3)) {
- ausgabe_Kontoinfo();
- }
- else {
- if (auswählen.equals(temp4)) {
- speichern();
- }
- else {
- fehler = "ungültige eingabe. Bitte eingabe überprüfen!";
- error();
- }
- }
- }
- }
- }
- } //end of main
- } //end of class
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement