-
Notifications
You must be signed in to change notification settings - Fork 1
/
clas.py
49 lines (41 loc) · 1.46 KB
/
clas.py
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
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Sat Oct 21 13:44:28 2017
@author: root
"""
class Company:
staffCount = 0
departmentCount = 0
def __init__(self, name, income, expenditure, departments):
self.name = name
self.income = income
self.expenditure = expenditure
self.departments = departments
Company.staffCount +=1
Company.departmentCount +=1
def comName(self):
print ("Company name is: ", self.name)
def displayComp(self):
print("Company name: ",self.name, "Income",self.income,"Expences",self.expenditure,"department",self.departments)
comp = Company("Skylabase", 1234567,123456,"CommuFi")
comp.displayComp()
print ("totsl nimber of departments %d" % Company.departmentCount,"total number of employees: %d"% Company.staffCount)
class Employee:
'Common base class for all employees'
empCount = 0
def __init__(self, name, salary):
self.name = name
self.salary = salary
Employee.empCount += 1
def displayCount(self):
print ("Total Employee %d" % Employee.empCount)
def displayEmployee(self):
print ("Name : ", self.name, ", Salary: ", self.salary)
"This would create first object of Employee class"
emp1 = Employee("Zara", 2000)
"This would create second object of Employee class"
emp2 = Employee("Manni", 5000)
emp1.displayEmployee()
emp2.displayEmployee()
print ("Total Employee %d" % Employee.empCount)