sync
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -42,4 +42,15 @@ public class Display {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
}
|
||||
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();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
BIN
Code/Loop.class
Normal file
BIN
Code/Loop.class
Normal file
Binary file not shown.
66
Code/Loop.java
Normal file
66
Code/Loop.java
Normal file
@@ -0,0 +1,66 @@
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class Loop {
|
||||
|
||||
public static Map<String, Integer> parseCommandLineArgs(String[] args) {
|
||||
Map<String, Integer> 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<String, Integer> 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.");
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user