My code:
class Attendee
def initialize(height)
@height = height
# raise 'The provided height is outside acceptable limits'
end
def height
@height
# raise 'Implement the Attendee#height method'
end
def pass_id
@pass_id
# if pass_id = nil
# @pass_id = nil
# else
# @pass_id = pass_id
# end
# raise 'Implement the Attendee#pass_id method'
end
def issue_pass!(pass_id)
@pass_id = pass_id
end
def revoke_pass!
@pass_id = nil
# raise 'Implement the Attendee#revoke_pass! method'
end
end
Initializing is a method used to give a class a value off the bat. In the case of the Amusement Park exercise, you are providing a value to the height variable
if pass_id = nil
@pass_id = nil
else
@pass_id = pass_id
end
This code initially worked because I was creating a new instance for pass_id, but was breaking the 4th test because it was preventing a value to be given to pass_id, it kept returning nil.
Things to remember:
MAKE SURE TO COMMENT OUT "raise" SO THAT IT WILL TEST PROPERLY
READ ALL OF THE INSTRUCTIONS MORE THAN ONCE AND TAKE NOTES
Top comments (0)