Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class TollGate
- def initialize(card, balance)
- @status = 0
- @card = card
- @balance = balance
- end
- def read_card
- true if @card == 'toll-card'
- false
- end
- def check_balance
- open_gate if @balance >= 3000
- close_gate
- end
- def open_gate
- @balance -= 3000
- @status = 1
- end
- def close_gate
- @status = 0
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement