-
Notifications
You must be signed in to change notification settings - Fork 0
/
classes-olena-zack.rb
102 lines (74 loc) · 2.13 KB
/
classes-olena-zack.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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
# For the following Task challenge use initialize, setter, and getter methods for your class.
# As a developer, I can create a class called Task.
# As a developer, I can create three instances (objects) of class Task. e.g laundry = Task.new
# As a developer, I can see the title of each instance of class Task.
# As a developer, I can initialize each instance of class Task with a status that has a default value of 'incomplete'.
# As a developer, I can update the status of each instance of class Task when the task has been completed.
class Task
def initialize(title)
@title = title
@status = 'incomplete'
end
def get_title
@title
end
def set_status(status)
@status = status
end
def get_status
@status
end
end
laundry = Task.new('laundry')
vacuum = Task.new('vacuum')
walk_dog = Task.new('walk dog')
p laundry.get_status
p vacuum.get_status
p walk_dog.get_status
laundry.set_status('almost done')
vacuum.set_status('completed')
walk_dog.set_status('almost done')
p laundry.get_status
p vacuum.get_status
p walk_dog.get_status
#--------------------------------------------------------------------------
# OPT 2 using boolian
# def get_task_status
# if @completed
# "The #{@title} is completed"
# else
# "You have not completed #{@title}it yet"
# end
# end
# def been_completed
# @completed = true
# end
# end
# p Task.new
# laundry = Task.new
# vacuum = Task.new
# laundry.been_completed
# vacuum.been_completed
# walk_dog.been_completed
# p laundry.get_task_status
# p vacuum.get_task_status
# p walk_dog.get_task_status# walk_dog = Task.new
# laundry.set_title('laundry')
# vacuum.set_title('vacuum')
# walk_dog.set_title('walk dog')
# p laundry.get_title
# p vacuum.get_title
# p walk_dog.get_title
# p laundry.get_task_status
# p vacuum.get_task_status
# p walk_dog.get_task_status
#
# p laundry.get_task_status
# p vacuum.get_task_status
# p walk_dog.get_task_status
# laundry.been_completed
# vacuum.been_completed
# walk_dog.been_completed
# p laundry.get_task_status
# p vacuum.get_task_status
# p walk_dog.get_task_status