Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- tester
- =======
- public class Tester {
- public static void main(String[] args)
- {
- /*
- Login myLogin = new Login();
- myLogin.userName="zeev";
- myLogin.passWord="1234";
- Login myLogin2 = new Login();
- myLogin2.userName="Nipo";
- myLogin2.passWord="2233";
- myLogin2.sayHello();
- System.out.println("");
- myLogin.sayHello();
- */
- /*
- Lion moshe = new Lion();
- moshe.name="Moshe";
- Lion lev = new Lion("Lev2");
- */
- /*
- Cow mush = new Cow();
- Cow mush2 = new Cow();
- Snake snaki = new Snake();
- */
- //System.out.println(lev.name+" Makes "+ lev.makeSound()+" is Alive:"+lev.isAlive);
- //System.out.println(moshe.name+" Makes "+ moshe.makeSound()+" is Alive:"+moshe.isAlive);
- Cow mush = new Cow();
- System.out.println(mush.makeSound());
- Lion lev = new Lion();
- lev.eatCow(mush);
- System.out.println(mush.makeSound());
- }
- }
- lion
- =====
- public class Lion
- {
- boolean isAlive;
- String name;
- String sound;
- public Lion()
- {
- this.isAlive=true;
- this.sound="Grrrr";
- }
- public Lion(String name)
- {
- this.name=name;
- this.isAlive=true;
- this.sound="Grrrr";
- }
- String makeSound()
- {
- return this.sound;
- }
- void die()
- {
- this.isAlive=false;
- }
- void eatCow(Cow myCow)
- {
- myCow.die();
- }
- }
- cow
- ==============
- public class Cow
- {
- boolean isAlive;
- String name;
- public Cow()
- {
- this.isAlive=true;
- }
- String makeSound()
- {
- if (isAlive)
- return "Muuu";
- else
- return "Dead Cow";
- }
- void die()
- {
- this.isAlive=false;
- }
- }
- snake
- ======
- public class Snake
- {
- boolean isAlive;
- String name;
- String makeSound()
- {
- return "sssss";
- }
- void die()
- {
- this.isAlive=false;
- }
- }
Add Comment
Please, Sign In to add comment