Browse Source

Optimizing: Price of Item is float now

feature-pr/shop
Maxim Volkov 3 years ago
parent
commit
f6511309b1
  1. 6
      projjpn/src/main/java/de/hs_fulda/ciip/projjpn/Item.java
  2. 7
      projjpn/src/test/java/de/hs_fulda/ciip/projjpn/ItemTest.java

6
projjpn/src/main/java/de/hs_fulda/ciip/projjpn/Item.java

@ -2,7 +2,7 @@ package de.hs_fulda.ciip.projjpn;
public class Item {
private int price;
private float price;
// customerReview
// productTitle
// description
@ -17,11 +17,11 @@ public class Item {
availability = newAmount;
}
public void updatePrice(int price) {
public void updatePrice(float price) {
this.price = price;
}
public int getCurrentPrice() {
public float getCurrentPrice() {
return price;
}
}

7
projjpn/src/test/java/de/hs_fulda/ciip/projjpn/ItemTest.java

@ -29,20 +29,19 @@ public class ItemTest extends TestCase {
// Given
Item item = new Item();
int quantity = 3;
int price = 5;
float price = 5;
item.updateAvailability(quantity);
item.updatePrice(price);
// When
int expectedPrice = quantity * price;
float expectedPrice = quantity * price;
// Then
int actualPrice = 0;
float actualPrice = 0;
for(int i = 0; i < quantity; i++) {
actualPrice += item.getCurrentPrice();
}
assertEquals(expectedPrice, actualPrice);
}
}
Loading…
Cancel
Save