Advertisement
Samorokimetal

Property 22.11.2020

Nov 22nd, 2020 (edited)
565
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.22 KB | None | 0 0
  1. public class Property {
  2.     private int number;
  3.     private String name;
  4.     private String address;
  5.     private double price;
  6.  
  7.     public Property (int number, String name, String address, double price){
  8.         this.setNumber(number);
  9.         this.setName(name);
  10.         this.setAddress(address);
  11.         this.setPrice(price);
  12.     }
  13.  
  14.     public int getNumber() {
  15.         return number;
  16.     }
  17.  
  18.     public void setNumber(int number) {
  19.         if (number > 0) {
  20.             this.number = number;
  21.         }
  22.     }
  23.  
  24.     public String getName() {
  25.         return name;
  26.     }
  27.  
  28.     public void setName(String name) {
  29.         this.name = name;
  30.     }
  31.  
  32.     public String getAddress() {
  33.         return address;
  34.     }
  35.  
  36.     public void setAddress(String address) {
  37.         this.address = address;
  38.     }
  39.  
  40.     public double getPrice() {
  41.         return price;
  42.     }
  43.  
  44.     public void setPrice(double price) {
  45.         if (price > 0) {
  46.             this.price = price;
  47.         }
  48.     }
  49.  
  50.     @Override
  51.     public String toString() {
  52.         return "[Number: " + this.number +
  53.                 ", name: " + this.name +
  54.                 ", address: " + this.address +
  55.                 ", price: " + this.price + "]";
  56.     }
  57. }
  58.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement