-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathProduct.java
50 lines (44 loc) · 1.49 KB
/
Product.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
import java.util.UUID;
public class Product {
public String id;
public String product;
public int qty;
public float cost;
public float amt;
public float tax;
public float total;
public String region;
public static Product parseObjectFromString(String s) {
String [] fields = s.split(" ");
return new Product(fields[0], fields[1], Integer.parseInt(fields[2]), Float.parseFloat(fields[3]),
Float.parseFloat(fields[4]), Float.parseFloat(fields[5]), Float.parseFloat(fields[6]),
fields[7]);
}
@Override
public String toString() {
return this.id + " " + this.product + " " + this.qty + " " + this.cost + " " + this.amt + " " + this.tax
+ " " + this.total + " " + this.region ;
}
public Product(String id, String product, int qty, float cost, float amt, float tax, float total,
String region){
this.id = id;
this.product = product;
this.qty = qty;
this.cost = cost;
this.amt = amt;
this.tax = tax;
this.total = total;
this.region = region;
}
public Product(String product, int qty, float cost, float amt, float tax, float total,
String region){
id = UUID.randomUUID().toString();
this.product = product;
this.qty = qty;
this.cost = cost;
this.amt = amt;
this.tax = tax;
this.total = total;
this.region = region;
}
}