-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcodebar_workshops_and_members.rb
More file actions
executable file
·78 lines (71 loc) · 2.01 KB
/
codebar_workshops_and_members.rb
File metadata and controls
executable file
·78 lines (71 loc) · 2.01 KB
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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
class Person
attr_reader :fullname
def initialize (fullname)
@fullname = fullname
end
end
class Student < Person
attr_reader :about
def initialize (fullname,about)
super(fullname)
@about = about
end
def print_details
"#{@fullname} - #{@about}"
end
end
class Coach < Person
attr_reader :bio, :skills
def initialize (fullname, bio)
super(fullname)
@bio = bio
@skills = []
end
def add_skill(*skill)
skill.each do |s|
@skills << s
end
end
def print_details
"#{@fullname} - #{@skills.join(", ")} - #{@bio}"
end
end
class Workshop
def initialize (date, venue_name)
@date = date
@venue_name = venue_name
@coaches = []
@students = []
end
def add_participant(member)
if member.is_a?(Student)
@students << member
elsif member.is_a?(Coach)
@coaches << member
end
end
def print_details
puts "Workshop - #{@date} - Venue: #{@venue_name}"
puts "Students"
@students.each_with_index do |s,i|
puts "#{i+1}. #{s.print_details}"
end
puts "Coaches"
@coaches.each_with_index do |c,i|
puts "#{i+1}. #{c.print_details}"
end
end
end
workshop = Workshop.new("12/03/2014", "Shutl")
jane = Student.new("Jane Doe", "I am trying to learn programming and need some help")
lena = Student.new("Lena Smith", "I am really excited about learning to program!")
vicky = Coach.new("Vicky Ruby", "I want to help people learn coding.")
vicky.add_skill("HTML")
vicky.add_skill("JavaScript")
nicole = Coach.new("Nicole McMillan", "I have been programming for 5 years in Ruby and want to spread the love")
nicole.add_skill("Ruby")
workshop.add_participant(jane)
workshop.add_participant(lena)
workshop.add_participant(vicky)
workshop.add_participant(nicole)
workshop.print_details