Skip to content

Commit

Permalink
ProductTest is fully working
Browse files Browse the repository at this point in the history
  • Loading branch information
fracz committed Jan 17, 2021
1 parent c00d71b commit 983a022
Showing 1 changed file with 19 additions and 9 deletions.
28 changes: 19 additions & 9 deletions src/main/java/pl/edu/agh/mwo/invoice/product/Product.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,24 +10,34 @@ public abstract class Product {
private final BigDecimal taxPercent;

protected Product(String name, BigDecimal price, BigDecimal tax) {
this.name = name;
if (name == null || name.equals("")) {
throw new IllegalArgumentException(
"You cannot create products with null or empty name."
);
}
if (price == null || price.signum() == -1) {
throw new IllegalArgumentException(
"You cannot create products with null or negative price."
);
}
this.name = name;
this.price = price;
this.taxPercent = tax;
}

public String getName() {
return null;
return this.name;
}

public BigDecimal getPrice() {
return null;
}
return price;
}

public BigDecimal getTaxPercent() {
return null;
}
public BigDecimal getTaxPercent() {
return taxPercent;
}

public BigDecimal getPriceWithTax() {
return null;
public BigDecimal getPriceWithTax() {
return this.price.multiply(this.taxPercent).add(this.price);
}
}

0 comments on commit 983a022

Please sign in to comment.