Skip to content

Commit 434ea82

Browse files
neha-peddintiactions-user
authored andcommitted
Bot: Prettified Java code!
1 parent 022ec37 commit 434ea82

File tree

4 files changed

+14
-15
lines changed

4 files changed

+14
-15
lines changed

src/com/codefortomorrow/advanced/chapter14/practice/Average.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
package com.codefortomorrow.advanced.chapter14.practice;
2+
23
import java.io.*;
34

45
/*
@@ -24,8 +25,8 @@ and display the average on the next (101st)
2425
*/
2526

2627
public class Average {
27-
public static void main(String[] args) {
2828

29+
public static void main(String[] args) {
2930
// Add code here.
3031
}
3132
}

src/com/codefortomorrow/advanced/chapter14/practice/Bank.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,9 @@ balance upon initialization (through the constructor).
2727
*/
2828

2929
public class Bank {
30-
31-
public static void main(String[] args) {
3230

31+
public static void main(String[] args) {
3332
// Your code here.
3433
}
3534
}
36-
3735
// Add other classes here.

src/com/codefortomorrow/advanced/chapter14/solutions/Average.java

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
package com.codefortomorrow.advanced.chapter14.solutions;
2+
23
import java.io.*;
34

45
/*
@@ -24,14 +25,15 @@ and display the average on the next (101st)
2425
*/
2526

2627
public class Average {
28+
2729
public static void main(String[] args) {
2830
File file = new File("numbers.txt");
29-
30-
// try with resources block, which closes streams automatically
31-
try(BufferedReader in = new BufferedReader(
32-
new FileReader(file)); BufferedWriter out = new BufferedWriter(
33-
new FileWriter(file, true))) {
3431

32+
// try with resources block, which closes streams automatically
33+
try (
34+
BufferedReader in = new BufferedReader(new FileReader(file));
35+
BufferedWriter out = new BufferedWriter(new FileWriter(file, true))
36+
) {
3537
// read the numbers (String input) and find average
3638
double average = 0;
3739
String contentLine = in.readLine();

src/com/codefortomorrow/advanced/chapter14/solutions/Bank.java

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ balance upon initialization (through the constructor).
2727
*/
2828

2929
public class Bank {
30-
30+
3131
public static void main(String[] args) {
3232
BankAccount account1 = new BankAccount(500);
3333
BankAccount account2 = new BankAccount(1000);
@@ -51,7 +51,6 @@ public static void withdraw(BankAccount account, int amount) {
5151
}
5252
}
5353

54-
5554
class BankAccount {
5655
private int balance;
5756

@@ -64,9 +63,9 @@ public void deposit(int amount) {
6463
}
6564

6665
public void withdraw(int amount) throws NotEnoughMoneyException {
67-
if(amount > balance)
68-
throw new NotEnoughMoneyException(
69-
"Bank balance is short $" + Math.abs(balance - amount));
66+
if (amount > balance) throw new NotEnoughMoneyException(
67+
"Bank balance is short $" + Math.abs(balance - amount)
68+
);
7069
balance -= amount;
7170
}
7271

@@ -75,7 +74,6 @@ public int getBalance() {
7574
}
7675
}
7776

78-
7977
class NotEnoughMoneyException extends Exception {
8078

8179
public NotEnoughMoneyException() {}

0 commit comments

Comments
 (0)