Advertisement
Promi_38

Address

Dec 7th, 2021
826
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.33 KB | None | 0 0
  1.  
  2. public class Address {
  3.  
  4.     String houseName = "";
  5.     String roadNo = "";
  6.     String area = "";
  7.     PostOffice PO;
  8.     String city = "";
  9.     Country country;
  10.  
  11.     Address(String houseName, String roadNo, String area, String city, Country country) {
  12.         this.houseName = houseName;
  13.         this.roadNo = roadNo;
  14.         this.area = area;
  15.         this.city = city;
  16.         this.country = country;
  17.     }
  18.  
  19.     Address(String houseName, String roadNo, PostOffice PO, String city, Country country) {
  20.         this.houseName = houseName;
  21.         this.roadNo = roadNo;
  22.         this.PO = PO;
  23.         this.city = city;
  24.         this.country = country;
  25.     }
  26.  
  27.     public void getAddress() {
  28.  
  29.         if (this.area != "") {
  30.             System.out.print("House name     : " + this.houseName + "\n"
  31.                     + "Road no        : " + this.roadNo + "\n"
  32.                     + "Area           : " + this.area + "\n"
  33.                     + "City           : " + this.city + "\n");
  34.             country.getCountry();
  35.         } else {
  36.             System.out.print("House name     : " + this.houseName + "\n"
  37.                     + "Road no        : " + this.roadNo + "\n");
  38.             PO.getPostOffice();
  39.             System.out.print("City           : " + this.city + "\n");
  40.             country.getCountry();
  41.         }
  42.     }
  43.  
  44. }
  45.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement