01 package tagSamples.netui_databinding.repeater.data;
02
03 import java.io.Serializable;
04
05 public class Order implements Serializable
06 {
07 public int orderID;
08 public String storeID;
09 public double value;
10 public int weight;
11 public OrderItem[] orderItems;
12 public String trackingID;
13
14 public Order() {}
15
16 public Order(int orderID, String storeID, double value, int weight,
17 OrderItem[] orderItems, String trackingID)
18 {
19 this.orderID = orderID;
20 this.storeID = storeID;
21 this.value = this.calculateValue(orderItems);
22 this.weight = this.calculateWeight(orderItems);
23 this.orderItems = orderItems;
24 this.trackingID = trackingID;
25 }
26
27 public double calculateValue(OrderItem[] orderItems)
28 {
29 value = 0.0;
30 for (int i = 0; i < orderItems.length; i++)
31 {
32 value += orderItems[i].itemQuantity * orderItems[i].itemPrice;
33 }
34 return value;
35 }
36
37 public int calculateWeight(OrderItem[] orderItems) {
38 weight = 0;
39 for (int i = 0; i < orderItems.length; i++) {
40 weight += orderItems[i].itemQuantity * 2;
41 }
42 return weight;
43 }
44 }
|