Guest User

class 1701

a guest
Jan 17th, 2016
47
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.75 KB | None | 0 0
  1. tester
  2. =======
  3.  
  4. public class Tester {
  5.  
  6.     public static void main(String[] args)
  7.     {
  8.         /*
  9.         Login myLogin = new Login();
  10.         myLogin.userName="zeev";
  11.         myLogin.passWord="1234";
  12.         Login myLogin2 = new Login();
  13.         myLogin2.userName="Nipo";
  14.         myLogin2.passWord="2233";
  15.         myLogin2.sayHello();
  16.         System.out.println("");
  17.         myLogin.sayHello();
  18.         */
  19.        
  20.         /*
  21.         Lion moshe = new Lion();
  22.         moshe.name="Moshe";
  23.         Lion lev = new Lion("Lev2");
  24.         */
  25.        
  26.         /*
  27.         Cow mush = new Cow();
  28.         Cow mush2 = new Cow();
  29.         Snake snaki = new Snake();
  30.         */
  31.        
  32.        
  33.         //System.out.println(lev.name+" Makes "+ lev.makeSound()+" is Alive:"+lev.isAlive);
  34.         //System.out.println(moshe.name+" Makes "+ moshe.makeSound()+" is Alive:"+moshe.isAlive);
  35.        
  36.         Cow mush = new Cow();
  37.         System.out.println(mush.makeSound());
  38.         Lion lev = new Lion();
  39.         lev.eatCow(mush);
  40.         System.out.println(mush.makeSound());
  41.     }
  42.  
  43. }
  44.  
  45.  
  46. lion
  47. =====
  48.  
  49. public class Lion
  50. {
  51.     boolean isAlive;
  52.     String name;
  53.     String sound;
  54.    
  55.     public Lion()
  56.     {
  57.         this.isAlive=true;
  58.         this.sound="Grrrr";
  59.     }
  60.    
  61.     public Lion(String name)
  62.     {
  63.         this.name=name;
  64.         this.isAlive=true;
  65.         this.sound="Grrrr";
  66.        
  67.     }
  68.    
  69.     String makeSound()
  70.     {
  71.         return this.sound;
  72.     }
  73.    
  74.     void die()
  75.     {
  76.         this.isAlive=false;
  77.     }
  78.    
  79.     void eatCow(Cow myCow)
  80.     {
  81.         myCow.die();
  82.     }
  83. }
  84.  
  85.  
  86. cow
  87. ==============
  88.  
  89. public class Cow
  90. {
  91.     boolean isAlive;
  92.     String name;
  93.    
  94.     public Cow()
  95.     {
  96.         this.isAlive=true;
  97.     }
  98.    
  99.     String makeSound()
  100.     {
  101.         if (isAlive)
  102.             return "Muuu";
  103.         else
  104.             return "Dead Cow";
  105.     }
  106.    
  107.     void die()
  108.     {
  109.         this.isAlive=false;
  110.     }
  111. }
  112.  
  113. snake
  114. ======
  115.  
  116. public class Snake
  117. {
  118.     boolean isAlive;
  119.     String name;
  120.    
  121.     String makeSound()
  122.     {
  123.         return "sssss";
  124.     }
  125.    
  126.     void die()
  127.     {
  128.         this.isAlive=false;
  129.     }
  130. }
Add Comment
Please, Sign In to add comment