-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathclass_user.rb
59 lines (47 loc) · 1.04 KB
/
class_user.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#!/bin/env ruby
class Person
#
# Defines basic info about person
#
attr_reader :name, :surname
def name=(fname)
# attribute writer
if fname != '' and fname != nil
@name = fname
else
raise "First name cannot be empty"
end
end
def surname=(lname)
# attribure writer
if lname != '' and lname != nil
@surname = lname
else
raise "Last name cannot be empty"
end
end
def initialize(fname,lname)
@name = fname
@surname = lname
end
def introduce
puts "Hi there! I'm #{@surname}, #{@name}"
end
end
class User < Person
#
# Represents registered user
#
attr_accessor :birthday, :email
def initialize(fname,lname, dob, fmail)
super(fname, lname)
@birthday = dob
@email = fmail
@subscriptions = []
end
def introduce
super
puts "I was born on #{@birthday}"
puts "My email : #{@email}"
end
end