Skip to content

Instantly share code, notes, and snippets.

@benwbrum
Created September 27, 2016 15:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save benwbrum/d773eb027ad8c1f5ad783338251be4d2 to your computer and use it in GitHub Desktop.
Save benwbrum/d773eb027ad8c1f5ad783338251be4d2 to your computer and use it in GitHub Desktop.
Coding challenge/interview prompt for Free UK Genealogy developer
# Create a Person class which will print the following output when run:
# Jane Doe
# John Smith
# YOUR CODE GOES HERE
p1 = Person.new
p1.first_name = 'Jane'
p1.last_name = 'Doe'
p1.print_name
p2 = Person.new('John', 'Smith')
p2.print_name
@CRodgers34
Copy link

class Person

Attr_accessor :first_name, :last_name

def initialize(first_name= “”,last_name= “”)
@first_name= first_name
@ last_name= last_name
end

def print_name
“#{first_name} #{ last_name}”
end
end
p1 = Person.new
p1.first_name = ‘Jane’
p1.last_name = ‘Doe’
p1.print_name

p2 = Person.new(Jane,smith)
p2.print_name

@CRodgers34
Copy link

class Person

Attr_accessor :first_name, :last_name

def initialize(first_name= “”,last_name= “”)
@first_name= first_name
@ last_name= last_name
end

def print_name
“#{first_name} #{ last_name}”
end
end
p1 = Person.new
p1.first_name = ‘Jane’
p1.last_name = ‘Doe’
p1.print_name

p2 = Person.new(Jane,smith)
p2.print_name

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment