Vexus

Exercise 3.10

Oct 8th, 2014
170
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.75 KB | None | 0 0
  1. package e310;
  2.  
  3. public class Product {
  4. public String name;
  5. public double price;
  6. public String getName(){
  7.         return name;
  8. }
  9. public double getPrice(){
  10.         return price;
  11. }
  12. public void reducePrice(){
  13.         price = price - 5;
  14. }
  15. public Product(String productName , double productPrice){
  16.         name = productName;
  17.         price =  productPrice;
  18. }
  19. }
  20. package e310;
  21.  
  22. public class ProductTester {
  23.  
  24.         public static void main(String[] args) {
  25.                 Product toaster = new Product("Toaster", 29.95);
  26.                 System.out.println(toaster.getName());
  27.                 System.out.println(toaster.getPrice());
  28.                 toaster.reducePrice();
  29.                 System.out.println(toaster.getPrice());
  30.         }
  31.  
  32. }
Advertisement
Add Comment
Please, Sign In to add comment