Created
November 24, 2016 15:46
-
-
Save Martin-Nyaga/ee63fe0284621638fb211ad32610883e to your computer and use it in GitHub Desktop.
This file contains 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
class ParkingTicket | |
def initialize(opts) | |
@day = opts[:day] || raise(":day is required") | |
@vehicle_type = opts[:vehicle_type] || raise(":vehicle_type is required") | |
@eet_passed = opts[:eet_passed] || raise(":eet_passed is required") | |
... | |
end | |
def base_fee | |
1000 | |
end | |
def total_cost | |
base_fee + surcharge | |
end | |
def surcharge | |
case @day | |
when "Monday", "Tuesday", "Wednesday", "Friday" | |
100 | |
when "Thursday", "Saturday", "Sunday" | |
150 | |
end | |
end | |
... | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment