Home
About
Blog
Products
Forum
Support
Contact
Sunbelt Computer Software
PL/B Language Development and Support
Home
About
Blog
Products
Forum
Support
Contact
python-challenges/Employee.py at main · dominicbiela/python-challenges · GitHub
Skip to content
Navigation Menu
Sign in
Appearance settings
Platform
AI CODE CREATION
GitHub Copilot
Write better code with AI
GitHub Copilot app
Direct agents from issue to merge
MCP Registry
Integrate external tools
DEVELOPER WORKFLOWS
Actions
Automate any workflow
Codespaces
Instant dev environments
Issues
Plan and track work
Code Review
Manage code changes
Code Quality
Enforce quality at merge
APPLICATION SECURITY
GitHub Advanced Security
Find and fix vulnerabilities
Code security
Secure your code as you build
Secret protection
Stop leaks before they start
EXPLORE
Why GitHub
Documentation
Blog
Changelog
Marketplace
View all features
Solutions
BY COMPANY SIZE
Enterprises
Small and medium teams
Startups
Nonprofits
BY USE CASE
App Modernization
DevSecOps
DevOps
CI/CD
View all use cases
BY INDUSTRY
Healthcare
Financial services
Manufacturing
Government
See all industries
View all solutions
Resources
EXPLORE BY TOPIC
AI
Software Development
DevOps
Security
View all topics
EXPLORE BY TYPE
Customer stories
Events & webinars
Ebooks & reports
Business insights
GitHub Skills
SUPPORT & SERVICES
Documentation
Customer support
Community forum
Trust center
Partners
View all resources
Open Source
COMMUNITY
GitHub Sponsors
Fund open source developers
PROGRAMS
Security Lab
Maintainer Community
GitHub Stars
Archive Program
REPOSITORIES
Topics
Trending
Collections
Enterprise
ENTERPRISE SOLUTIONS
Enterprise platform
AI-powered developer platform
AVAILABLE ADD-ONS
GitHub Advanced Security
Enterprise-grade security features
Copilot for Business
Enterprise-grade AI features
Premium Support
Enterprise-grade 24/7 support
Pricing
Search
/
Sign in
Sign up
Appearance settings
You signed in with another tab or window.
Reload
to refresh your session.
You signed out in another tab or window.
Reload
to refresh your session.
You switched accounts on another tab or window.
Reload
to refresh your session.
Dismiss alert
{{ message }}
dominicbiela
python-challenges
Repository navigation
Code
Issues
Pull requests
Actions
Projects
Security and quality
Insights
More
items
Files
Expand file tree
main
Breadcrumbs
python-challenges
/
Employee.py
Copy path
Blame
More file actions
Blame
More file actions
Latest commit
History
History
History
92 lines (73 loc) · 2.63 KB
main
Breadcrumbs
python-challenges
/
Employee.py
Copy path
Top
File metadata and controls
Code
Blame
92 lines (73 loc) · 2.63 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
"""
This is an environment to build out Object-Oriented Programming
"""
class
Employee
:
raise_amount
=
1.05
def
__init__
(
self
,
first
,
last
,
job
,
salary
):
self
.
first
=
first
self
.
last
=
last
self
.
job
=
job
self
.
salary
=
salary
self
.
email
=
f'
{
first
}
.
{
last
}
@email.com'
@
property
def
fullname
(
self
)
->
str
:
return
f'
{
self
.
first
}
{
self
.
last
}
'
@
fullname
.
setter
def
fullname
(
self
,
name
):
first
,
last
=
name
.
split
(
" "
)
self
.
first
=
first
self
.
last
=
last
def
apply_raise
(
self
)
->
int
:
self
.
salary
=
int
(
self
.
salary
*
self
.
raise_amount
)
return
self
.
salary
# classmethod overrides the class global variable (set at the top)
@
classmethod
def
set_raise_amt
(
cls
,
amount
)
->
int
:
cls
.
raise_amount
=
amount
@
classmethod
def
from_string
(
cls
,
string
):
first
,
last
,
job
,
salary
=
string
.
split
(
"-"
)
return
cls
(
first
,
last
,
job
,
salary
)
def
__repr__
(
self
)
->
str
:
class_name
=
type
(
self
).
__name__
return
f'
{
class_name
}
(
{
self
.
first
}
{
self
.
last
}
,
{
self
.
job
}
,
{
self
.
salary
}
)'
def
__str__
(
self
)
->
str
:
return
f"The Employee's name is
{
self
.
first
}
{
self
.
last
}
and their job title is
{
self
.
job
}
"
class
Developer
(
Employee
):
raise_amount
=
float
(
1.10
)
def
__init__
(
self
,
first
:
str
,
last
:
str
,
job
:
str
,
salary
:
float
,
prog_lang
:
str
):
super
().
__init__
(
first
,
last
,
job
,
salary
)
self
.
prog_lang
=
prog_lang
class
Manager
(
Employee
):
def
__init__
(
self
,
first
:
str
,
last
:
str
,
job
:
str
,
salary
:
float
,
employees
:
list
[
str
]
|
None
=
None
):
super
().
__init__
(
first
,
last
,
job
,
salary
)
if
employees
is
None
:
self
.
employees
=
[]
else
:
self
.
employees
=
employees
def
add_emp
(
self
,
employee
:
Employee
):
if
employee
not
in
self
.
employees
:
return
self
.
employees
.
append
(
employee
)
else
:
print
(
'Already managing'
)
def
remove_emp
(
self
,
employee
:
Employee
):
if
employee
in
self
.
employees
:
return
self
.
employees
.
remove
(
employee
)
else
:
print
(
'Not currently managed'
)
def
print_emps
(
self
):
for
emp
in
self
.
employees
:
print
(
emp
.
fullname
)
emp_1
=
Employee
(
'Bob'
,
'Biela'
,
'Data Engineer'
,
100000
)
print
(
repr
(
emp_1
))
print
(
emp_1
.
salary
)
print
(
emp_1
.
apply_raise
())
dev_1
=
Developer
(
'Dominic'
,
'Biela'
,
'Data Engineer'
,
500000
,
'Python'
)
print
(
dev_1
.
email
)
man_1
=
Manager
(
'Jermey'
,
'Brown'
,
'Manager'
,
550000
)
man_1
.
add_emp
(
dev_1
)
man_1
.
add_emp
(
emp_1
)
man_1
.
add_emp
(
dev_1
)
print
(
man_1
.
employees
)
man_1
.
remove_emp
(
'Dominic Biela'
)
print
(
man_1
.
print_emps
())
You can’t perform that action at this time.