Advertisement
Guest User

Untitled

a guest
Sep 18th, 2019
178
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.35 KB | None | 0 0
  1. class TollGate
  2. def initialize(card, balance)
  3. @status = 0
  4. @card = card
  5. @balance = balance
  6. end
  7.  
  8. def read_card
  9. true if @card == 'toll-card'
  10. false
  11. end
  12.  
  13. def check_balance
  14. open_gate if @balance >= 3000
  15. close_gate
  16. end
  17.  
  18. def open_gate
  19. @balance -= 3000
  20. @status = 1
  21. end
  22.  
  23. def close_gate
  24. @status = 0
  25. end
  26. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement