Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Nico Vigil PR #5

Open
wants to merge 14 commits into
base: master
Choose a base branch
from
Open

Conversation

nicovigil1
Copy link

Nonstop thrill-ride into the exploration of Ruby

end

def price_per_hour
@cost
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You could alternatively name @cost @price_per_hour and put it in the attr_reader

def rent(boat, renter)
@boats << boat
@renters << renter
@boats_and_owners[renter] = boat
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like this idea of keeping the owner associated with a boat using a hash

@revenue += boat.cost
end

@boats.map do |boat|
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be an each since you are only using the map to access each boat

end

def return(boat)
delete_this_boat = @boats.find_index do |ship|
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this could be a delete_if

dock.rent(kayak_1, ringo)

assert_instance_of Renter, dock.renters.last
assert_instance_of Boat, dock.boats.last
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You shouldn't just assert it's a boat, you sure assert the EXACT boat. You have access to it. It's called kayak_1. Same thing for ringo

kayak_1 = Boat.new(:kayak, 20)
dock.rent(kayak_1, ringo)

assert_equal kayak_1, dock.return(kayak_1)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doesn't feel like it's testing what the return method should do. According to what your method does, the return method should remove the boat from the array. This feels like a test for the sake of having a test.

dock.log_hour
dock.log_hour
dock.log_hour # should add 20 to 40 (60)
dock.log_hour # shouldn't add anything
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like the comments

#if I had more time I would have had the methods work off of @boats_and_owners
#so that the owners were better connected with their boats. The thought crossed
#my mind but I wanted to make sure I could finish this iteration.
end
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The next thing you should do is write another test that the revenue works with multiple boats.

require "./lib/renter"
require "./lib/boat"

class DockTest < Minitest::Test
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Keep working on your TDD. You are showing improvement. Keep it up!

@@ -0,0 +1,42 @@
require "pry"
class Dock
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great job! I like your logic in solving this problem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants