Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package ch3;
- public class producttester {
- public static void main(String[] args) {
- // TODO Auto-generated method stub
- product lightBulb = new product("Light Bulb", 29.99);
- lightBulb.getName();
- lightBulb.getPrice();
- lightBulb.reducePrice(5);
- lightBulb.getPrice();
- product carrot = new product("carrot", 19.99);
- carrot.getName();
- carrot.getPrice();
- carrot.reducePrice(5);
- carrot.getPrice();
- }
- }
- ********************************************************************************************************************************
- package ch3;
- public class product {
- private String product;
- private double price;
- public product(String productName, double productPrice){
- product = productName;
- price = productPrice;
- }
- public void getName(){
- System.out.println(product);
- }
- public void getPrice(){
- System.out.println(price);
- }
- public void reducePrice(double discount){
- double reduce = discount;
- price = price - reduce;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement