File tree Expand file tree Collapse file tree 2 files changed +11
-1
lines changed
src/main/java/pl/edu/agh/mwo/invoice Expand file tree Collapse file tree 2 files changed +11
-1
lines changed Original file line number Diff line number Diff line change 11package pl .edu .agh .mwo .invoice ;
22
33public class Demo {
4+ public static final String SDLKFJSDKJFLKSDJFLK = "" ;
5+
46 public static void main (String [] args ) {
5- System .out .println (0.1 + 0.2 );
7+ // System.out.println(0.1 + 0.2);
8+ System .out .println (" " .trim ().isEmpty ());
69 }
710}
Original file line number Diff line number Diff line change 11package pl .edu .agh .mwo .invoice .product ;
22
3+ import java .io .IOException ;
34import java .math .BigDecimal ;
45
56public abstract class Product {
@@ -10,6 +11,12 @@ public abstract class Product {
1011 private final BigDecimal taxPercent ;
1112
1213 protected Product (String name , BigDecimal price , BigDecimal tax ) {
14+ if (name == null || name .equals ("" )) {
15+ throw new IllegalArgumentException ("Product name cannot be null." );
16+ }
17+ if (price == null || price .compareTo (BigDecimal .ZERO ) == -1 ) {
18+ throw new IllegalArgumentException ("Price of the product cannot be null or negative." );
19+ }
1320 this .name = name ;
1421 this .price = price ;
1522 this .taxPercent = tax ;
You can’t perform that action at this time.
0 commit comments