1 27 package olstore.client; 28 29 import java.text.DecimalFormat; 30 31 34 public class OrderItem extends Item { 35 36 37 private int quantity; 38 39 43 public OrderItem(Item item) { 44 super(item.getTitle(), item.getDescription(), item.getPrice(), item 45 .getCategory(), item.getId(), item.getImage()); 46 47 quantity = 1; 48 } 49 50 54 public int getQuantity() { 55 return quantity; 56 } 57 58 62 public void setQuantity(int quantity) { 63 this.quantity = quantity; 64 } 65 66 69 public boolean equals(Object other) { 70 return getId().equals(((OrderItem) other).getId()); 71 } 72 73 77 public double getTotal() { 78 DecimalFormat formatter = new DecimalFormat("#.00"); 79 return (double) quantity 80 * Double.valueOf(super.getPrice()).doubleValue(); 81 } 82 } 83 | Popular Tags |