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

Completed Daily Challenge - Caffeine #2

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
language: ruby
rvm:
- 2.2.2

script: caffeine_test.rb
script: coffee.rb
script: human.rb
2 changes: 1 addition & 1 deletion caffeine_tests.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def test_humans_can_drink_coffee

mallory.buy tsmf
mallory.drink!
assert_within_epsilon mallory.alertness, 0.33, 0.1
assert_in_epsilon mallory.alertness, 0.33, 0.1
refute tsmf.full?
refute tsmf.empty?
end
Expand Down
19 changes: 18 additions & 1 deletion coffee.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,20 @@
class Coffee
# Add code here

def initialize(type)
@full = true
@sips = 3
end

def full?
@sips == 3
end

def take_sip
@sips -= 1
end

def empty?
@sips.zero?
end

end
29 changes: 28 additions & 1 deletion human.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,30 @@
class Human
# Add code here

attr_reader :alertness

def initialize(name)
@alertness = 0
end

def buy coffee
@my_coffee = coffee
end

def drink!
@alertness += 0.33
@my_coffee.take_sip
end

def has_coffee?
if @my_coffee.nil?
false
else
true
end
end

def needs_coffee?
not has_coffee?
end

end