1 package org.wcb.e6b;
2
3 import org.wcb.e6b.vo.WeightLineItem;
4
5 import java.util.ArrayList;
6
7
8
9
10
11
12
13
14
15 public class WeightBalanceE6B extends AbstractE6B {
16
17 private ArrayList<WeightLineItem> lineitems;
18 private long weightTotal;
19 private double momentTotal;
20 private double armTotal;
21
22 public ArrayList<WeightLineItem> getLineitems() {
23 return lineitems;
24 }
25
26 public void setLineitems(ArrayList<WeightLineItem> lineitems) {
27 this.lineitems = lineitems;
28 }
29
30
31 public void calculate() {
32 weightTotal = 0;
33 for (WeightLineItem item : lineitems) {
34 item.calculate();
35 weightTotal = weightTotal + item.getWeight();
36 momentTotal = momentTotal + item.getMoment();
37 armTotal = momentTotal / weightTotal;
38 }
39 }
40
41 public long getTotalWeight() {
42 return weightTotal;
43 }
44
45 public double getMomentTotal() {
46 return momentTotal;
47 }
48
49 public double getArmTotal() {
50 return Math.rint(armTotal * 100) / 100;
51 }
52 }