Advertisement
NB52053

Practise_Nadui

Jul 15th, 2017
276
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.46 KB | None | 0 0
  1. For Nadui practise ......
  2.  
  3. /**
  4.  * Created by ltnb on 7/16/17.
  5.  */
  6. public class Main {
  7.     public static void main(String[] args) {
  8.         Person p1=new Person("Mugabe", "Zimbabwe");
  9.         Person p2 = new Person("MaMa", "La La Land");
  10.         Person atel1 = p1;
  11.  
  12.  
  13.         //System.out.println(p1.name);
  14.         //System.out.println(p1.countryName);
  15.  
  16.        // p1.print();
  17.         trip(p1, p2);
  18.         System.out.println(p1.name);
  19.         System.out.println(p1.countryName);
  20.  
  21.  
  22.         //p2.universeFriend(p1);
  23.         p1.print();
  24.         p2.print();
  25.  
  26.  
  27.     }
  28.     public static void trip(Person p1, Person p2) {
  29.         Person atel1 = p1;
  30.         Person atel2 = new Person("Momin", "Honolulu");
  31.        p1 = atel2;
  32.  
  33.         //System.out.println(p1.name);
  34.         //System.out.println(p1.countryName);
  35.  
  36.         p2.print();
  37.         p2.name = atel2.name;
  38.         p2.countryName = p1.countryName;
  39.  
  40.         p2.print();
  41.     }
  42. }
  43.  
  44.  
  45.  
  46.  
  47.  
  48. /**
  49.  * Created by ltnb on 7/16/17.
  50.  */
  51. class Person{
  52.     public String name;
  53.     public String countryName;
  54.     public Person uniF;
  55.     public Person(String name, String
  56.             countryName) {
  57.         this.name = name;
  58.         this.countryName = countryName;
  59.     }
  60.     public void print(){
  61.         System.out.println(name+" "+
  62.                 countryName);
  63.     }
  64.     public void universeFriend(Person p){
  65.         uniF = p;
  66.         uniF.countryName = "Uganda";
  67.     }
  68. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement