public BigDecimal calculateTotal() {
BigDecimal percent = BigDecimal.valueOf(0.9);
int i = 0;
BigDecimal price = BigDecimal.valueOf(0.0);
while(!myOrders.isEmpty()){
if (!myOrders.get(i).getItem().isBulk() && myMembership == true){
price = price.add(myOrders.get(i).calculateOrderTotal().multiply(percent));
myOrders.remove(i);
}
else{
price = price.add(myOrders.get(i).calculateOrderTotal());
myOrders.remove(i);
}
}
//WHY IS THIS UNREACHABLE?!
return price.setScale(2, RoundingMode.HALF_EVEN);
}
I know that anything after a return statement is unreachable code, but my only return statement is unreachable and I can't figure out why. The while loop is the way it is because I'm grasping at straws, I'm aware that it probably won't do what I want it to do. myOrders is an ArrayList.
Cleaning eclipse solved the problem.