Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 2b1e101

Browse files
committed
Minor code style changes
1 parent 059844d commit 2b1e101

File tree

10 files changed

+30
-61
lines changed

10 files changed

+30
-61
lines changed

‎chapter8/src/main/java/com/manning/spock/chapter8/eshop/Basket.java‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,7 @@ public void setWarehouseInventory(WarehouseInventory warehouseInventory) {
5454
}
5555

5656
public boolean canShipCompletely() {
57-
if(warehouseInventory.isEmpty())
58-
{
57+
if(warehouseInventory.isEmpty()) {
5958
return false;
6059
}
6160
try {

‎chapter8/src/main/java/com/manning/spock/chapter8/eshop/BillableBasket.java‎

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,7 @@ public void setCreditCardProcessor(CreditCardProcessor creditCardProcessor) {
1010
this.creditCardProcessor = creditCardProcessor;
1111
}
1212

13-
public boolean checkout(Customer customer)
14-
{
13+
public boolean checkout(Customer customer) {
1514
CreditCardResult result = creditCardProcessor.sale(findOrderPrice(), customer);
1615
creditCardProcessor.shutdown();
1716

@@ -28,7 +27,4 @@ private int findOrderPrice() {
2827
return sum;
2928
}
3029

31-
32-
33-
3430
}

‎chapter8/src/main/java/com/manning/spock/chapter8/eshop/CreditCardProcessor.java‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,7 @@ public void shutdown(){
1111
System.out.println("Shutting down");
1212
}
1313

14-
public boolean online()
15-
{
14+
public boolean online() {
1615
return true;
1716
}
1817
}

‎chapter8/src/main/java/com/manning/spock/chapter8/eshop/WarehouseInventory.java‎

Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,7 @@ public class WarehouseInventory {
77

88
protected Map<String,Integer> inventory = new HashMap<>();
99

10-
public void preload(Product product, int times)
11-
{
10+
public void preload(Product product, int times) {
1211
if(times <0)
1312
{
1413
times = 0;
@@ -19,38 +18,31 @@ public void preload(Product product, int times)
1918
public void subtract(String productName, Integer times) {
2019
int now = inventory.get(productName);
2120
int after = now - times;
22-
if(after == 0)
23-
{
21+
if(after == 0) {
2422
inventory.remove(productName);
2523
}
26-
else
27-
{
24+
else {
2825
inventory.put(productName, after);
2926
}
3027

3128

3229
}
3330

34-
public int isProductAvailable(String productName)
35-
{
36-
if(inventory.containsKey(productName))
37-
{
31+
public int isProductAvailable(String productName) {
32+
if(inventory.containsKey(productName)) {
3833
return inventory.get(productName);
3934
}
4035
else throw new IllegalArgumentException("Uknown product "+productName);
4136
}
4237

43-
public boolean isProductAvailable(String productName,int count)
44-
{
38+
public boolean isProductAvailable(String productName,int count) {
4539
int now = isProductAvailable(productName);
4640
return count <= now;
4741
}
4842

49-
public boolean isEmpty()
50-
{
43+
public boolean isEmpty() {
5144
return inventory.isEmpty();
5245
}
5346

54-
5547

5648
}

‎chapter8/src/main/java/com/manning/spock/chapter8/loan/CreditCard.java‎

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,13 @@
22

33
public class CreditCard {
44

5-
private String holder;
5+
private int totalAmountSpent;
6+
private int amountDue;
67

7-
public CreditCard(String number)
8-
{
8+
public CreditCard(String number) {
99

1010
}
11-
private int totalAmountSpent;
12-
private int amountDue;
11+
1312
public int getTotalAmountSpent() {
1413
return totalAmountSpent;
1514
}
@@ -22,13 +21,11 @@ public int getAmountDue() {
2221
public void setAmountDue(int amountDue) {
2322
}
2423

25-
public void assign(BankAccount bankAccount)
26-
{
24+
public void assign(BankAccount bankAccount) {
2725

2826
}
2927

30-
public void setHolder(String name)
31-
{
28+
public void setHolder(String name) {
3229

3330
}
3431

‎chapter8/src/main/java/com/manning/spock/chapter8/loan/Customer.java‎

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -24,20 +24,16 @@ public void setName(String name) {
2424
}
2525

2626

27-
public void requests(Loan loan)
28-
{
27+
public void requests(Loan loan) {
2928
boolean result = true;
30-
if(getCards().size()>=3)
31-
{
29+
if(getCards().size()>=3) {
3230
result = false;
3331
}
34-
if(loan.getAmount() > 500.000)
35-
{
32+
if(loan.getAmount() > 500.000) {
3633
result = false;
3734
}
3835

39-
if(result)
40-
{
36+
if(result) {
4137
loan.getContactDetails().setAddress(getAddress());
4238
loan.getContactDetails().setCity(getCity());
4339
loan.getContactDetails().setName(getName());
@@ -48,8 +44,7 @@ public void requests(Loan loan)
4844
loan.setApproved(result);
4945
}
5046

51-
public void owns(CreditCard creditCard)
52-
{
47+
public void owns(CreditCard creditCard) {
5348
cards.add(creditCard);
5449
}
5550

‎chapter8/src/main/java/com/manning/spock/chapter8/nuker/CameraFeed.java‎

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,11 @@ public class CameraFeed {
77

88
private Image image;
99

10-
public void setCurrentFrame(Image image)
11-
{
10+
public void setCurrentFrame(Image image) {
1211
this.image = image;
1312
}
1413

15-
public Image getCurrentFrame()
16-
{
14+
public Image getCurrentFrame() {
1715
return image;
1816
}
1917

‎chapter8/src/main/java/com/manning/spock/chapter8/nuker/HardDriveNuker.java‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,7 @@
22

33
public class HardDriveNuker {
44

5-
public void deleteHardDriveNow()
6-
{
5+
public void deleteHardDriveNow() {
76
System.out.println("Cleaning hard disk");
87
}
98
}

‎chapter8/src/main/java/com/manning/spock/chapter8/nuker/SmartHardDriveNuker.java‎

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,14 @@
22

33
public class SmartHardDriveNuker extends HardDriveNuker{
44

5-
public void activate(CameraFeed cameraFeed)
6-
{
7-
if( physicalIntrusionDetected(cameraFeed))
8-
{
5+
public void activate(CameraFeed cameraFeed) {
6+
if( physicalIntrusionDetected(cameraFeed)) {
97
deleteHardDriveNow();
108
}
119
}
1210

1311

14-
private boolean physicalIntrusionDetected(CameraFeed cameraFeed)
15-
{
12+
private boolean physicalIntrusionDetected(CameraFeed cameraFeed) {
1613
System.out.println("Complex image recognition analysis - real code");
1714
return true;
1815
}

‎chapter8/src/main/java/com/manning/spock/chapter8/nuker2/SmartHardDriveNuker.java‎

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,22 +7,19 @@ public class SmartHardDriveNuker{
77

88
private final HardDriveNuker hardDriveNuker;
99

10-
public SmartHardDriveNuker(final HardDriveNuker hardDriveNuker)
11-
{
10+
public SmartHardDriveNuker(final HardDriveNuker hardDriveNuker) {
1211
this.hardDriveNuker = hardDriveNuker;
1312
}
1413

15-
public void activate(CameraFeed cameraFeed)
16-
{
14+
public void activate(CameraFeed cameraFeed) {
1715
if( physicalIntrusionDetected(cameraFeed))
1816
{
1917
hardDriveNuker.deleteHardDriveNow();
2018
}
2119
}
2220

2321

24-
private boolean physicalIntrusionDetected(CameraFeed cameraFeed)
25-
{
22+
private boolean physicalIntrusionDetected(CameraFeed cameraFeed) {
2623
System.out.println("Complex image recognition analysis - real code");
2724
return true;
2825
}

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /