Created
September 27, 2016 15:06
-
-
Save benwbrum/d773eb027ad8c1f5ad783338251be4d2 to your computer and use it in GitHub Desktop.
Coding challenge/interview prompt for Free UK Genealogy developer
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 |
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
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