Ruby Build an Address Book in Ruby Class Design Contact Class: Part 2

Alphonse Cuccurullo
Alphonse Cuccurullo
2,513 Points

def To_s isnt right but i dont know what is wrong with it.

'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' class Contact

attr_writer :first_name, :middle_name, :last_name

def first_name @first_name end

def middle_name @middle_name end

def last_name @last_name end

def last_first last_first = last_name last_first += " " last_first += first_name if !@middle_name.nil? last_first += " " last_first += middle_name.slice(0, 1) last_first += "." end return last_first end def first_last fir = first_name fir += " " fir += last_name if !middle_name.nil? fir += " " fir += middle_name.slice(0,1) fir += last_name end

def to_s(format = 'full_name') case format when "full_name" full_name when "last_first" last_first when "first_name" first_name when "last" last_name end first_last end end def full_name full_name = first_name if !@middle_name.nil? full_name += " " full_name += middle_name end full_name += ' ' full_name += last_name full_name end end

al = Contact.new al.first_name = "Alphonse" al.middle_name = "Lawrence" al.last_name = "Cuccurullo" puts al.to_s("last_first") puts al.last_first puts al.full_name puts "\n" nick = Contact.new nick.first_name = "Nick" nick.middle_name = "joseph" nick.last_name = "Cuccurullo" puts nick.full_name puts "\n" jason = Contact.new jason.first_name = "Jason" jason.last_name = "gordon" puts jason.last_first puts jason.full_name ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''

Caitlin Palmer-Bright
Caitlin Palmer-Bright
11,309 Points

Hard to see without the ruby formatting. Can you try reposting with the formatting 'button' checked? Or even take a screen shot?