-
-
Save uncoded-ro/94e018bf8ded6307dae3902283e2ba38 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package ro.virtualcampus.app; | |
import java.io.*; | |
import ro.virtualcampus.bank.Cont; | |
import ro.virtualcampus.bank.FonduriInsuficiente; | |
public class Banca { | |
static BufferedReader fin = new BufferedReader(new InputStreamReader(System.in)); | |
public static boolean valid(char optiune) { | |
char[] optiuni = { 'd', 'r', 's', 'i' }; | |
for (int i = 0; i < optiuni.length; i++) { | |
if (optiune == optiuni[i]) | |
return true; | |
} | |
return false; | |
} | |
public static void main(String args[]) { | |
Cont c = new Cont("RO12SV00009999124"); | |
char optiune; | |
do { | |
System.out.println("{ d - depunere, r - retragere, s - sold, i - iesire }"); | |
optiune = 's'; | |
try { | |
optiune = fin.readLine().charAt(0); | |
switch (optiune) { | |
case 'd': | |
System.out.println("Suma depusa: "); | |
c.depune(Double.valueOf(fin.readLine())); | |
break; | |
case 'r': | |
System.out.println("Suma retrasa: "); | |
c.retrage(Double.valueOf(fin.readLine())); | |
break; | |
case 's': | |
System.out.println("Sold disponibil: " + c.getSold()); | |
break; | |
} | |
} catch (FonduriInsuficiente e) { | |
System.out.println("fonduri insuficiente"); | |
System.out.println("necesar: " + e.getSuma()); | |
} catch (IOException e) { | |
System.out.println("eroare citire \n"); | |
} catch (NumberFormatException e) { | |
System.out.println("valoare gresita \n"); | |
} | |
} while (valid(optiune) && optiune != 'i'); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment