Skip to content

Commit c86c708

Browse files
committed
Fixed cosmetic issues with lessons 11 and 12
1 parent 29357c4 commit c86c708

File tree

16 files changed

+24
-23
lines changed

16 files changed

+24
-23
lines changed

Lesson-11/Activities/ChallengeActivity1-ATMPin/src/fudgebanking/ATM.java

Lines changed: 2 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -57,32 +57,12 @@ SAMPLE RUN (three invalid attempts)
5757
public class ATM {
5858

5959
public static void main(String[] args) {
60-
//TODO: Write your code here.
6160
System.out.printf("*********************************\n");
6261
System.out.printf("*** Welcome to FudgeBank ATM! ***\n");
6362
System.out.printf("*********************************\n\n");
6463
Scanner input = new Scanner(System.in);
65-
BankAccount myacct = new BankAccount("1234", 500);
66-
int attempts = 0;
67-
boolean success= false;
68-
while(true) {
69-
System.out.print("Enter PIN # ==> ");
70-
String pin = input.nextLine();
71-
attempts++;
72-
if (pin.equals(myacct.Pin())) {
73-
success = true;
74-
break;
75-
}
76-
if (attempts >= 3) {
77-
success = false;
78-
break;
79-
}
80-
}
81-
if (success) {
82-
menu();
83-
} else {
84-
System.out.println("You entered an invalid pin 3 times!");
85-
}
64+
//TODO: Write your code here.
65+
8666
}
8767

8868
public static void menu() {

Lesson-11/SOLUTIONS/Solution-ChallengeActivity1-ATMPin/src/fudgebanking/ATM.java

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,28 @@ public static void main(String[] args) {
6262
System.out.printf("*********************************\n\n");
6363
Scanner input = new Scanner(System.in);
6464
//TODO: Write your code here.
65-
65+
BankAccount myacct = new BankAccount("1234", 500);
66+
int attempts = 0;
67+
boolean success= false;
68+
while(true) {
69+
System.out.print("Enter PIN # ==> ");
70+
String pin = input.nextLine();
71+
attempts++;
72+
if (pin.equals(myacct.Pin())) {
73+
success = true;
74+
break;
75+
}
76+
if (attempts >= 3) {
77+
success = false;
78+
break;
79+
}
80+
}
81+
if (success) {
82+
menu();
83+
} else {
84+
System.out.println("You entered an invalid pin 3 times!");
85+
}
86+
6687
}
6788

6889
/** main menu of ATM */

0 commit comments

Comments
 (0)