Advertisement
Guest User

Untitled

a guest
Apr 24th, 2017
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.91 KB | None | 0 0
  1. package product;
  2.  
  3. public class CashRegister
  4. {
  5.  
  6. private double totalPrice;
  7.  
  8. public void settotalPrice(double thetotalPrice)
  9. {
  10. totalPrice = thetotalPrice;
  11. }
  12. public double gettotalPrice()
  13. {
  14. return totalPrice;
  15. }
  16.  
  17.  
  18. private int totalProducts;
  19.  
  20. public void settotalProducts(int thetotalProducts)
  21. {
  22. totalProducts = thetotalProducts;
  23. }
  24. public int gettotalProducts()
  25. {
  26. return totalProducts;
  27. }
  28.  
  29. public void Scan(Product aProduct)
  30. {
  31. totalPrice = totalPrice + aProduct.getPrice();
  32. totalProducts ++;
  33.  
  34. }
  35.  
  36. public void displayTotalProducts()
  37. {
  38. System.out.println("You have purchased " + this.gettotalProducts() + " items" );
  39. }
  40. public void displayTotalPurchase()
  41. {
  42. System.out.println("Total: $" + this.gettotalPrice());
  43. }
  44.  
  45. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement