Advertisement
Guest User

Untitled

a guest
Sep 27th, 2016
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.66 KB | None | 0 0
  1. package ai152.velichko;
  2.  
  3. /**
  4.  * Created by User on 24.09.2016.
  5.  */
  6. public class Item {
  7.     private String name;
  8.     private float price;
  9.  
  10.     Item(String name, float price) {
  11.         if ( price < 0 ){
  12.             this.price = 0;
  13.         } else {
  14.             this.price = price;
  15.         }
  16.         this.name = name;
  17.     }
  18.  
  19.     public void raiseItemPrice(float percent) {
  20.         price = price + price * percent / 100;
  21.     }
  22.  
  23.     public void cutItemPrice(float percent) {
  24.         price = price - price * percent / 100;
  25.         if (percent>100){
  26.             price = 0;
  27.         }
  28.     }
  29.  
  30.     public float getPrice (){
  31.         return price;
  32.     }
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement