Advertisement
JoshJurban

Exercise 3.10 Constructor/Methods

Oct 8th, 2014
182
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.40 KB | None | 0 0
  1. package product;
  2.  
  3. public class Product
  4. {
  5.  
  6.     private String name;
  7.     private double price;
  8.    
  9.     public Product(String productName, double productPrice)
  10.     {
  11.         name = productName;
  12.         price = productPrice;
  13.     }
  14.  
  15.     public String getName()
  16.     {
  17.         return name;
  18.     }
  19.    
  20.     public double getPrice()
  21.     {
  22.         return price;
  23.     }
  24.    
  25.     public void reducePrice(double reducedPrice)
  26.     {
  27.         price = price - reducedPrice;
  28.     }
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement