daily pastebin goal
1%
SHARE
TWEET

Untitled

a guest Feb 20th, 2019 55 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. public class zad2{
  2.     public static void main(String[] args){
  3.         Lokator lokator = new Lokator("Piotr", "Nowak", true);
  4.         Dom dom = new Dom(new Adres("Krakow", "Rakowicka", "3"));
  5.        
  6.         dom.dodajLokatora(new Lokator("Piotr", "Nowak", true));
  7.         System.out.println(dom.toString());
  8.     }
  9. }
  10.  
  11. class Lokator{
  12.     private String name;
  13.     private String surname;
  14.     private boolean zameldowany;
  15.    
  16.     public Lokator(String name, String surname, boolean zameldowany){
  17.         this.name=name;
  18.         this.surname=surname;
  19.         this.zameldowany=zameldowany;
  20.     }
  21.    
  22.     public String toString(){
  23.         return name + " " + surname + " " + String.valueOf(zameldowany);
  24.     }
  25. }
  26.  
  27. class Adres{
  28.     private String miasto;
  29.     private String ulica;
  30.     private String numer;
  31.    
  32.     public Adres(String miasto, String ulica, String numer){
  33.         this.miasto=miasto;
  34.         this.ulica=ulica;
  35.         this.numer=numer;
  36.     }
  37.    
  38.     public String toString(){
  39.         return miasto + " " + ulica + " " + numer;
  40.     }
  41. }
  42.  
  43. class Dom implements DodajeLokatora{
  44.     private Adres adres;
  45.     private Lokator lokator;
  46.    
  47.     public Dom(Adres adres){
  48.         this.adres=adres;
  49.     }
  50.    
  51.     public String toString(){
  52.         return lokator + " " + adres;
  53.     }
  54.    
  55.     public void dodajLokatora(Lokator lokator){
  56.         this.lokator=lokator;
  57.     }
  58. }
  59.  
  60. interface DodajeLokatora{
  61.     public void dodajLokatora(Lokator lokator);
  62. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top