Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class Product
- {
- private double price;
- private String name;
- /**
- Constructs a product with a given name and price.
- @param name the name
- @param price the price
- */
- public Product(String n, double p)
- {name = n;
- price = p;}
- /**
- Gets the product name.
- @return the name
- */
- public String getName()
- { return name;}
- /**
- Gets the product price.
- @return the price
- */
- public double getPrice()
- { return price; }
- /**
- Reduces the product price.
- @param amount the amount by which to reduce the price
- */
- public double reducePrice(double amount)
- { return price = price - amount;}
- public double price()
- { return price;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement