Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Ruby

Alphonse Cuccurullo
Alphonse Cuccurullo
2,513 Points

Require load file Error (require "./phone"

so it is telling me that it cant require the file phone. Load error. Also something about a kernel. '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''require "./phone"

require "./address_part"

class Contact

attr_writer :first_name, :middle_name, :last_name attr_reader :phone_numbers, addresses

def initialize @phone_numbers [] @addresses = [] end

def add_phone_number(kind, number) phone_number = PhoneNumber.new phone_number.kind = kind phone_number.number = number phone_numbers.push(phone_number) end

def add_address(kind, street_1, street_2, city, state, postal_code) address = Address.new address.kind = kind address.street_1 = street_1 address.street_2 = street_2 address.city = city address.state = state address.postal_code = postal_code addresses.push(address) end

def print_addresses puts "Addresses" addresses.each { |address| puts address.to_s('short') } end

def first_name @first_name end

def middle_name @middle_name end

def last_name @last_name end

def first_last first_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 =begin 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 first_last first_name + " " + 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

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

 def print_phone_numbers
puts "Phone Numbers"
phone_numbers.each { |phone_number| puts phone_number }

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 al.add_phone_number("Home","1718-847-3216") al.add_phone_number("Cell", "1718-913-4120") al.add_address("Home", "123 Main St.", "", "Portland", "OR", "12345") 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 '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''