-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathemployee_LMO.py
More file actions
31 lines (24 loc) · 849 Bytes
/
employee_LMO.py
File metadata and controls
31 lines (24 loc) · 849 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
#Créer une classe employee
#Avec une méthode __init__ qui prend name et salary comme paramètres
#Créer une variable de classe globale, faire des recherches sur le net
#Créer une méthode displaycount qui affiche le nombre d'employés
#Créer une méthode display qui affiche un employé
class Employee:
nEmployee = 0
def __init__(self, name, salary):
self.name = name
self.salary = salary
Employee.nEmployee += 1
def __str__(self):
return '[Employee[name : {}, salary : {} ]]'.format(self.name, self.salary)
def display(self):
print('nom : ', self.name, ', salaire : ', self.salary)
def displaycount(self):
print(Employee.nEmployee)
a = Employee('Toto', 200)
a.displaycount()
a.display()
b = Employee('Riri', 250)
b.displaycount()
b.display()
print(Employee.nEmployee)