From ef0043ada8cd2b5256a4f41f54f7493180ed5270 Mon Sep 17 00:00:00 2001 From: Ali Can Zeybek Date: Thu, 9 Jan 2025 20:32:47 +0300 Subject: [PATCH] sync --- Code/ATM.java | 28 ++++++++++++++++++++ Code/Display.java | 13 ++++++++- Code/Loop.class | Bin 0 -> 415 bytes Code/Loop.java | 66 ++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 106 insertions(+), 1 deletion(-) create mode 100644 Code/Loop.class create mode 100644 Code/Loop.java diff --git a/Code/ATM.java b/Code/ATM.java index 60b5e5e..00f6836 100644 --- a/Code/ATM.java +++ b/Code/ATM.java @@ -5,6 +5,9 @@ public class ATM { private int minimumAmount; private int maximumAmount; private int limitTimeForOperation; + private int totalFund; + private int maximum_withdrawar_pday_pacc; + private int maximum_withdrawar_ptrans; /** * @@ -62,5 +65,30 @@ public class ATM { public void setLimitTimeForOperation(int limitTimeForOperation) { this.limitTimeForOperation = limitTimeForOperation; } + + public int getMaximum_withdrawar_pday_pacc() { + return maximum_withdrawar_pday_pacc; + } + + public void setMaximum_withdrawar_pday_pacc(int maximum_withdrawar_pday_pacc) { + this.maximum_withdrawar_pday_pacc = maximum_withdrawar_pday_pacc; + } + + public int getMaximum_withdrawar_ptrans() { + return maximum_withdrawar_ptrans; + } + + public void setMaximum_withdrawar_ptrans(int maximum_withdrawar_ptrans) { + this.maximum_withdrawar_ptrans = maximum_withdrawar_ptrans; + } + + + public int getTotalFund() { + return totalFund; + } + + public void setTotalFund(int totalFund) { + this.totalFund = totalFund; + } } diff --git a/Code/Display.java b/Code/Display.java index 3bd95e7..36db3b5 100644 --- a/Code/Display.java +++ b/Code/Display.java @@ -42,4 +42,15 @@ public class Display { throw new UnsupportedOperationException(); } -} \ No newline at end of file + public static String get_default_display() { + StringBuilder sb = new StringBuilder(); // Use StringBuilder for efficiency + sb.append("------------------------------------\n"); + sb.append("Welcome to the ATM\n"); + sb.append("1. Check Balance\n"); + sb.append("2. Withdraw Cash\n"); + sb.append("3. Deposit Cash\n"); + sb.append("------------------------------------\n"); + return sb.toString(); + } + +} diff --git a/Code/Loop.class b/Code/Loop.class new file mode 100644 index 0000000000000000000000000000000000000000..703d505919783d73fe9448c6319454bb50007fe5 GIT binary patch literal 415 zcmZvY%}T>S6ot=i(oPdoTU%Ry3w9y2BIW_AZUk{rREX4ttE3&ulq6GPBKTOkP;lV` z_)y}Vx)7nWxaZEyxgVGF_5JY);0#?CC0GKshcYUJ#yorq{Wwf#{!KKOlbldFRjJC) z308kFc2I>Q;Cfht_sjle&o=QS}q*8fZB$3SS z!YJk!I|&sNI{k-L2!b2vBAdudWz3F&otS0NLz^=)rvx%7aoyrumz7w{NAI8)ZV204 m&9~_t>|mGGSPz$@fb$B`ti7TBXE*r+7RPF{d5`-N_J05}&r-?& literal 0 HcmV?d00001 diff --git a/Code/Loop.java b/Code/Loop.java new file mode 100644 index 0000000..eb868a8 --- /dev/null +++ b/Code/Loop.java @@ -0,0 +1,66 @@ +import java.util.HashMap; +import java.util.Map; + +public class Loop { + + public static Map parseCommandLineArgs(String[] args) { + Map parameters = new HashMap<>(); + try { + for (int i = 0; i < args.length; i++) { + if (args[i].startsWith("-")) { + String parameterName = args[i].substring(1); + if (i + 1 < args.length) { + try { + int parameterValue = Integer.parseInt(args[i + 1]); + parameters.put(parameterName, parameterValue); + i++; + } catch (NumberFormatException e) { + System.err.println("Error: Invalid value for parameter " + parameterName + ": " + args[i + 1]); + return null; + } + } else { + System.err.println("Error: Missing value for parameter " + parameterName); + return null; + } + } else { + System.err.println("Warning: Ignoring invalid argument: " + args[i]); + } + } + } catch (Exception e) { + System.err.println("An unexpected error occurred: " + e.getMessage()); + return null; + } + + return parameters; + } + + public static void main(String[] args) { + Map atmParams = parseCommandLineArgs(args); + + if (atmParams != null) { + int t = atmParams.getOrDefault("t", 0); + int k = atmParams.getOrDefault("k", 0); + int m = atmParams.getOrDefault("m", 0); + int n = atmParams.getOrDefault("n", 0); + + ATM atm = new ATM(); + CardReader cr = new CardReader(atm); + Display display = new Display(); + display.display(Display.get_default_display()); + atm.setMinimumAmount(n); + atm.setTotalFund(t); + atm.setMaximum_withdrawar_pday_pacc(k); + atm.setMaximum_withdrawar_ptrans(m); + + while (true) { + + if ATM.checkAvailabilityOfCashInATM() + // TODO wait for signal from + + } + + } else { + System.err.println("Failed to initialize ATM parameters from command line."); + } + } +}