Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package product;
- public class CashRegister
- {
- private double totalPrice;
- public void settotalPrice(double thetotalPrice)
- {
- totalPrice = thetotalPrice;
- }
- public double gettotalPrice()
- {
- return totalPrice;
- }
- private int totalProducts;
- public void settotalProducts(int thetotalProducts)
- {
- totalProducts = thetotalProducts;
- }
- public int gettotalProducts()
- {
- return totalProducts;
- }
- public void Scan(Product aProduct)
- {
- totalPrice = totalPrice + aProduct.getPrice();
- totalProducts ++;
- }
- public void displayTotalProducts()
- {
- System.out.println("You have purchased " + this.gettotalProducts() + " items" );
- }
- public void displayTotalPurchase()
- {
- System.out.println("Total: $" + this.gettotalPrice());
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement