-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathOOP lab instructions.txt
More file actions
81 lines (42 loc) · 1.66 KB
/
OOP lab instructions.txt
File metadata and controls
81 lines (42 loc) · 1.66 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
79
80
81
# Lab Instructions: Object Oriented Programming
## Task 1: Code a Person class
Code a Person class, with three parameters in the constructor: name, age, and energy.
Set the default parameters in the Person class as follows:
name = "Tom"
age = 20
energy = 100
Code two methods in the Person class. Name those methods sleep() and doSomethingFun().
The sleep() method should take the existing energy level and increase it by 10.
The doSomethingFun() method should take the existing energy level and decrease it by 10.
<br><br>
## Task 2: Code a Worker class
Code a sub-class, inheriting from the Person class, and name it Worker.
The Worker class has two additional parameters in the constructor:
- xp (for "experience points")
- hourlyWage.
These properties are set to the following default values:
xp = 0
hourlyWage = 10
The Worker class has all the paramerters and methods of its super-class.
Additionally, it has the goToWork() method, which, whenever it's run, increases the value of the xp property by 10.
<br><br>
## Task 3: Code a intern object
Inside the intern function instantiate the Worker class to code a new intern object.
The intern should have the following characteristics:
name: Bob
age: 21
energy: 110
xp: 0
hourlyWage: 10
Run the goToWork() method on the intern object. Then return the intern object.
<br><br>
## Task 4: Code a manager object
Inside the manager function instantiate the Worker class to code a new manager object.
The manager object should have the following characteristics:
name: Alice
age: 30
energy: 120
xp: 100
hourlyWage: 30
Run the doSomethingFun() method on the manager object. Then return the manager object.
<br><br>