forked from fenyx-it-academy/Class5-Python-Module-Week5
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathWeek05_Hw_4.py
More file actions
34 lines (23 loc) · 835 Bytes
/
Week05_Hw_4.py
File metadata and controls
34 lines (23 loc) · 835 Bytes
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
'''## Question 4:
* Define the `Employee` class with an `__init__()` method
* Define a class variable `new_id` and set it equal to `1`
* Each Employee instance will need its own unique ID. Thus, inside `__init__()`,
define `self.id` and set it equal to the class variable `new_id`
* Lastly, increment `new_id` by `1`
* Define a `say_id()` method
* Inside `say_id()`, output the string `"My id is "` and then the instance id.
* Define the variable e1 and set it to an instance of Employee
* Define the variable e2 and set it to an instance of Employee
* Have both e1 and e2 output their ids
'''
class Employee:
new_id=1
def __init__(self):
self.id=Employee.new_id
Employee.new_id +=1
def say_id(self):
print (f"My ID is ", self.id)
e1=Employee()
e2=Employee()
e1.say_id()
e2.say_id()