Advertisement
chrisenoch

LineItem.java

Oct 3rd, 2019
113
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.80 KB | None | 0 0
  1. package murach.business;
  2. import java.io.Serializable;
  3. import java.text.NumberFormat;
  4. public class LineItem implements Serializable {
  5.  
  6. private Product product;
  7. private int quantity;
  8. public LineItem() {}
  9.  
  10. public void setProduct(Product p) {
  11. product = p;
  12. }
  13.  
  14. public Product getProduct() {
  15. return product;
  16. }
  17.  
  18. public void setQuantity(int quantity) {
  19. this.quantity = quantity;
  20. }
  21.  
  22. public int getQuantity() {
  23. return quantity;
  24. }
  25.  
  26. public double getTotal() {
  27. double total = product.getPrice() * quantity;
  28. return total;
  29. }
  30.  
  31. public String getTotalCurrencyFormat() {
  32. NumberFormat currency = NumberFormat.getCurrencyInstance();
  33. return currency.format(this.getTotal());
  34. }
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement