SHARE
TWEET

animals

a guest Sep 22nd, 2019 122 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. class Lion{
  2.     let sound="Roar!!!!!"
  3.     var name:String
  4.     var isAlive = true
  5.  
  6.     init (name:String)
  7.     {
  8.         self.name=name
  9.     }
  10.  
  11.     func makeSound(){
  12.         if self.isAlive
  13.         {
  14.             print ("\(name) make sound:\(sound)")
  15.         }
  16.     }
  17.  
  18.     func eat(cow:Cow){
  19.         cow.isAlive=false
  20.     }
  21. }
  22.  
  23. class Cow{
  24.     let sound="Muuuuuuuuu"
  25.     var name:String
  26.     var isAlive=true
  27.  
  28.     init(name:String){
  29.         self.name=name
  30.     }
  31.  
  32.     func giveMilk(cat:Cat)->Bool{
  33.         return self.isAlive
  34.     }
  35.  
  36.     func makeSound(){
  37.         if self.isAlive
  38.         {
  39.              print ("\(name) make sound:\(sound)")
  40.         } else {
  41.             print ("\(self.name) is dead, alla yerchamu ! neo bad girl")
  42.         }
  43.     }
  44. }
  45.  
  46. class Cat{
  47.     let sound="Miaooo , pussycat"
  48.     var name:String
  49.     var isAlive=true
  50.  
  51.     init(name:String){
  52.         self.name=name
  53.     }
  54.  
  55.     func drinkMilk(cow:Cow)->Bool{
  56.         if cow.isAlive(){
  57.             print ("milk, yammi yammi")
  58.         } else {
  59.             print ("WTF, i dont drink blood")
  60.         }
  61.     }
  62.  
  63.     func makeSound(){
  64.         if self.isAlive
  65.         {
  66.              print ("\(name) make sound:\(sound)")
  67.         } else {
  68.             print ("\(self.name) is dead, alla yerchamu ! neo bad girl")
  69.         }
  70.     }
  71.  
  72.     func eatMouse (mouse:Mouse){
  73.         mouse.isAlive=false
  74.     }
  75.  
  76. }
  77.  
  78. class Mouse{
  79.      let sound="Swiqqq Swiqqq"
  80.     var name:String
  81.     var isAlive=true
  82.  
  83.     init(name:String){
  84.         self.name=name
  85.     }
  86.  
  87.     func makeSound(){
  88.         if self.isAlive
  89.         {
  90.              print ("\(name) make sound:\(sound)")
  91.         } else {
  92.             print ("\(self.name) is dead, alla yerchamu ! neo bad girl")
  93.         }
  94.     }
  95. }
  96.  
  97. var lev=Lion(name: "lev")
  98. var mush=Cow(name: "mush")
  99.  
  100. lev.makeSound()
  101. mush.makeSound()
  102. print ("cow give milk:\(mush.giveMilk())")
  103. lev.eat(cow: mush)
  104. mush.makeSound()
  105. print ("cow give milk:\(mush.giveMilk())")
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
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top