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 1
1
package pl .edu .agh .mwo .invoice ;
2
2
3
3
public class Demo {
4
+ public static final String SDLKFJSDKJFLKSDJFLK = "" ;
5
+
4
6
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 ());
6
9
}
7
10
}
Original file line number Diff line number Diff line change 1
1
package pl .edu .agh .mwo .invoice .product ;
2
2
3
+ import java .io .IOException ;
3
4
import java .math .BigDecimal ;
4
5
5
6
public abstract class Product {
@@ -10,6 +11,12 @@ public abstract class Product {
10
11
private final BigDecimal taxPercent ;
11
12
12
13
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
+ }
13
20
this .name = name ;
14
21
this .price = price ;
15
22
this .taxPercent = tax ;
You can’t perform that action at this time.
0 commit comments