Created
April 17, 2018 07:49
-
-
Save X1ting/fa99fa0e73dd8bad0841df872873ba8f to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| module Cash | |
| def pay(amount) | |
| self.cash = self.cash + amount | |
| end | |
| end | |
| class Kino | |
| include Cash | |
| attr_accessor :cash | |
| def buy | |
| pay(10) | |
| end | |
| end | |
| class Netflix | |
| extend Cash | |
| class << self | |
| attr_accessor :cash | |
| def buy | |
| pay(10) | |
| end | |
| end | |
| end | |
| puts 'KINO' | |
| kino = Kino.new | |
| kino.cash = 20 | |
| puts kino.cash | |
| kino.buy | |
| puts kino.cash | |
| puts 'KINO END' | |
| puts 'NETFLIX' | |
| Netflix.cash = 20 | |
| puts Netflix.cash | |
| Netflix.buy | |
| puts Netflix.cash | |
| puts 'NETFLIX END' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment