Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- [<AbstractClass>]
- type Food(name: string, amount: int) =
- let name = name
- let mutable amount = amount
- let mutable toeat = 0
- type Fruit(name: string, amount: int) =
- inherit Food(name, amount)
- let mutable amountofBananas = amount
- let mutable amountofApples = amount
- member this.amountofBanan = amountofBananas
- member this.amountofApple = amountofApples
- member this.BananGetLess toeat =
- let a = amount - toeat
- match (a) with
- |0 -> amountofBananas <- a
- printfn "You just have ate the last banan!"
- |_ -> if a > 0 then printfn "It was tasty ^_^"
- amountofBananas <- a
- else printfn "You don't have any bananas!"
- member this.AppleGetLess toeat =
- let a = amount - toeat
- match (a) with
- |0 -> amountofApples <- a
- printfn "You just have ate the last apple!"
- |_ -> if a > 0 then printfn "It was tasty ^_^"
- amountofApples <- a
- else printfn "You don't have enough apples!"
- let Banan = new Fruit("Banan", 10)
- let Apple = new Fruit("Apple", 10)
- printfn "amount of bananas %A " Banan.amountofBanan
- type Animal(name: string, mood: int) =
- let name = name
- let mutable mood = mood
- member this.moodincrease point =
- mood <- mood + point
- member this.eatBanan toeat =
- Banan.BananGetLess toeat
- this.moodincrease 5
- member this.eatApple toeat =
- Apple.AppleGetLess toeat
- this.moodincrease 10
- member this.Drinkcoffee =
- this.moodincrease 40
- member this.Mood = mood
- member this.ReceiveCake = printfn "%A says : I HATE FISH" name
- type Cat(name: string, mood: int) =
- inherit Animal(name, mood)
- let mutable lives = 9
- let Monkey = new Animal("Monkey", 30)
- Monkey.eatBanan 10
- Monkey.Drinkcoffee
- Monkey.ReceiveCake
- type Human(name: string, skills: int) =
- let name = name
- let f = 1
- let mutable skills = skills
- let mutable amountofcakes = 0
- member this.MakeFishCake =
- amountofcakes <- amountofcakes + 1
- skills <- skills + 1
- member this.PresentCake (animal: Animal) =
- match (amountofcakes) with
- |0 -> printfn "This human doesn't have enough cakes"
- |_ -> if amountofcakes > 0 then animal.ReceiveCake
- amountofcakes <- amountofcakes - 1
- else printfn "This Human doesn't have enough cakes"
- let Tim = new Cat("Tim", 12)
- let Charls = new Human("Charls", 0)
- Charls.PresentCake Monkey
- Charls.MakeFishCake
- Charls.PresentCake Tim
- printfn "amount of bananas %A " Banan.amountofBanan
- printfn "amount of apples %A " Apple.amountofApple
- printfn "Monkey's mood is: %A" Monkey.Mood
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement