Skip to content
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
74 changes: 44 additions & 30 deletions birthday_cake.rb
Original file line number Diff line number Diff line change
@@ -1,30 +1,30 @@
=begin
birthday_cake.rb

It's your birthday! Yay! 🎂
# birthday_cake.rb

Can you debug this BirthdayCake class in time to sing happy birthday? 🎶
# It's your birthday! Yay! 🎂

Tip: Resolve the error messages before trying to make it work
# Can you debug this BirthdayCake class in time to sing happy birthday? 🎶

Expected output:
Happy 10th Birthday!
Birthday cake with 10 blown out candles
Lighting candles...
Birthday cake with 10 lit candles
Singing happy birthday...
🎶Happy birthday to you, happy birthday to you🎶
Blowing out candles...
Birthday cake with 10 blown out candles
# Tip: Resolve the error messages before trying to make it work

# Expected output:
# Happy 10th Birthday!
# Birthday cake with 10 blown out candles
# Lighting candles...
# Birthday cake with 10 lit candles
# Singing happy birthday...
# 🎶Happy birthday to you, happy birthday to you🎶
# Blowing out candles...
# Birthday cake with 10 blown out candles

=end

require "active_support/all"

class BirthdayCake
attr_accessor :age, :lit

def initialize(age)
#add lit
def initialize(age, lit)
self.age = age
self.lit = false
end
Expand All @@ -36,34 +36,48 @@ def candles_status
return "blown out"
end
end

#try (self.age).ordinalize
def greet
"Happy #{self.age.ordinalize} Birdday!"
"Happy #{self.age.ordinalize} Birthday!"
end

def sing
"🎶Happy birthday to you, happy birthday to you🎶"
end

#candle status maybe not in {}
def to_s
"Birthday cake with #{self.age} #{candles_status} candles"
end

def BirthdayCake.celebrate(age)
birthday_cake = Birthdaycake.new(age)
puts birthday_cake.greet
puts birthday_cake.to_s
def light_candles
self.lit = true
end

def blow_out_candles
self.lit = false
end


#should only be celebrate. birthday_cake should be outside of method.
def celebrate(age)
#birthday_cake(age) = Birthdaycake.new
puts greet
puts to_s
puts "Lighting candles..."
birthday_cake.light_candles
puts birthday_cake.to_s
light_candles
puts to_s
puts "Singing happy birthday..."
puts birthday_cake.sign
# #what is this? sing probably?
puts sing
puts "Blowing out candles..."
birth_cake.blow_out_candles
puts birthday_cake.to_s

birthday_cake
# #bithday_cake. there is not blow out candles
# birth_cake.blow_out_candles
puts to_s
# #what is this?
#birthday_cake
end
end

BirthdayCake.celebrate(10)
birthday_cake = BirthdayCake.new(10, false)
birthday_cake.celebrate(10)
57 changes: 57 additions & 0 deletions birthday_cake_redux.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
require "active_support/all"

class BirthdayCake
attr_accessor :age, :lit

def initialize(age)
self.age = age
self.lit = false
end

def candles_status
if self.lit == true
return "lit"
else
return "blown out"
end
end

def greet
"Happy #{self.age.ordinalize} Birdday!"
end

def sing
"🎶Happy birthday to you, happy birthday to you🎶"
end

def to_s
"Birthday cake with #{self.age} #{candles_status} candles"
end

def light_candles
self.lit = true
end

def blow_out_candles
self.lit = false
end


def BirthdayCake.celebrate(age)
birthday_cake = BirthdayCake.new(age)
puts birthday_cake.greet
puts birthday_cake.to_s
puts "Lighting candles..."
birthday_cake.light_candles
puts birthday_cake.to_s
puts "Singing happy birthday..."
puts birthday_cake.sing
puts "Blowing out candles..."
birthday_cake.blow_out_candles
puts birthday_cake.to_s

birthday_cake
end
end

BirthdayCake.celebrate(10)
78 changes: 78 additions & 0 deletions birthday_cake_review.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
=begin
birthday_cake.rb

It's your birthday! Yay! 🎂

Can you debug this BirthdayCake class in time to sing happy birthday? 🎶

Tip: Resolve the error messages before trying to make it work

Expected output:
Happy 10th Birthday!
Birthday cake with 10 blown out candles
Lighting candles...
Birthday cake with 10 lit candles
Singing happy birthday...
🎶Happy birthday to you, happy birthday to you🎶
Blowing out candles...
Birthday cake with 10 blown out candles

=end

require "active_support/all"

class BirthdayCake
attr_accessor :age, :lit

def initialize(age)
self.age = age
self.lit = false
end

def candles_status
if self.lit == true
return "lit"
else
return "blown out"
end
end

def greet
"Happy #{self.age.ordinalize} Birthday!"
end

def sing
"🎶Happy birthday to you, happy birthday to you🎶"
end

def to_s
"Birthday cake with #{self.age} #{candles_status} candles"
end

def light_candles
return self.lit = true
end

def blow_out_candles
return self.lit = false
end


def celebrate(age)
puts greet
puts to_s
puts "Lighting candles..."
light_candles
puts to_s
puts "Singing happy birthday..."
puts sing
puts "Blowing out candles..."
blow_out_candles
puts to_s
end

end

#birthday_cake
birthday_cake = BirthdayCake.new(10)
birthday_cake.celebrate(10)