Devvision

Logic

Jun 28th, 2016
41
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.86 KB | None | 0 0
  1. package main;
  2.  
  3. class Commodity {
  4.     private String name;
  5.     private int quantity;
  6.     private double price;
  7.    
  8.     Commodity() {
  9.     }
  10.    
  11.     Commodity(String name) {
  12.         this.name = name;
  13.     }
  14.    
  15.     Commodity(String name, int quantity) {
  16.         this.name = name;
  17.         this.quantity = quantity;
  18.     }
  19.    
  20.     Commodity(String name, int quantity, double price) {
  21.         this.name = name;
  22.         this.quantity = quantity;
  23.         this.price = price;
  24.     }
  25.  
  26.  
  27.     String getName() {
  28.         return name;
  29.     }
  30.  
  31.     void setName(String name) {
  32.         this.name = name;
  33.     }
  34.  
  35.     int getQuantity() {
  36.         return quantity;
  37.     }
  38.  
  39.     void setQuantity(int quantity) {
  40.         this.quantity = quantity;
  41.     }
  42.  
  43.     double getPrice() {
  44.         return price;
  45.     }
  46.  
  47.     void setPrice(double price) {
  48.         this.price = price;
  49.     }
  50.    
  51.     @Override
  52.     public String toString() {
  53.         return "[name=" + name + ", quantity=" + quantity + ", price=" + price + "]";
  54.     }
  55.    
  56. }
Add Comment
Please, Sign In to add comment