Question: Create the following classes: class Employee: Create a default class called Employee. An employee should include seven pieces of information as instance variables: 1 .
Create the following classes:
class Employee:
Create a default class called Employee. An employee should include seven pieces of information as
instance variables:
name: the name of the employee
id: an automatically generated string based on the year this employee was hired digits this
employee was the th employee hired digits For example, the th employee of the company
who was hired in should be
hireyear: the year that the employee was hired.
username: automatically generated string based on the following rules:
a Get the first character of the employees first name
b Get the employees entire last name
c Join them together, and make each character lowercase
d Add a number at the end based on how many existing usernames that are the same to make sure
that all usernames are unique
For example, if the employees name is David Smith and dsmithdsmith and dsmith already
exist, then Davids username should be dsmith
rank: an integer value in the range of to to show this employees level within the company. The
higher the number is the higher rank this employee holds.
yearlypayment: the employees income for this year.
department: an object of the class Department. The department the employee works in
Also, create a static variable, called employees, a dictionary to store all the employee objects that have
been created. Each employees id should be the key, and the value should be a list with their name,
username, rank, yearlypayment, and department in this order.
An example is given below:
: Alex Smith', 'asmith a department object
: Adam Smith', 'asmith a department object
: Allison Smith', 'asmith a department object
: Andrew Smith', 'asmith None
Tasks:
Add constructor. The attributes, name, hireyear, yearlypayment, and rank, must be specified. The
attributes, id and username, are generated automatically. The initial value of the attribute,
department, should be None if not specified.
Add a get method for each attribute.
Add a set method for the attribute, name.
Add a promote method to promote an employees rank by one. This employees yearlypayment
should also be increased by dollars for each promotion.
Employee objects should be comparable based on their ranks.
ltself other To get called on comparison using operator.
leself other To get called on comparison using operator.
eqself other To get called on comparison using operator.
neself other To get called on comparison using operator.
geself other To get called on comparison using operator.
gtself other To get called on comparison using operator.
Add a str method to return a string with this employees information: name, id username, rank,
yearlypayment, and department.
You may add some private utility methods to facilitate your design.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
