Question

Design and write a class named Employee that inherits the Person class from the previous exercise...

Design and write a class named Employee that inherits the Person class from the previous exercise and holds the following additional data: ID number, department and job title. Once you have completed the Employee class, write a Python program that creates three Employee objects to hold the following data:

Name ID Number Department Job Title Phone
Susan Meyers 47899 Accounting Vice President 212-555-1212
Mark Jones 39119 IT Programmer 212-555-2468
Joy Rogers 81774 Operations Engineer 212-555-9753


The Python program should store this data in the three objects and then display the data for each employee on the screen.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Code for class Person and class Employee in Python ::

Explanation is provided in code itself in form of comments.

'''
Person class that have constructor which take first name,
last name and phone number in string format.
Person class have two method i.e Name(return first name and last name)
and Phone(returns phone number)
'''
class Person():
    def __init__(self,first,last,phone):
        self.firstName=first
        self.lastName=last
        self.phone=phone
    def Name(self):
        return self.firstName+" "+self.lastName
    def Phone(self):
        return self.phone

'''
Employee class inherits from Person class and have three extra parameters
of its own i.e ID number, Department and Job Title.
here initialization method takes following parameters
first name,last name, phone, id, department, jobtitle.
Method printEmp returns the required data in given format.
'''
class Employee(Person):
    def __init__(self,first,last,phone,id,department,jobTitle):
        super().__init__(first,last,phone)
        self.idNum=id
        self.department=department
        self.jobTitle=jobTitle
    def printEmp(self):
        return self.Name()+" "+self.idNum+" "+self.department+" "+self.jobTitle+" "+self.Phone()

'''
Now creating three objects named susan, mark and joy.
All required data is passed in string format.
And all objects are printed lastly!
'''

susan=Employee("Susan","Meyers","212-555-1212","47899","Accounting","Vice President")
mark=Employee("Mark","Jones","212-555-2468","39119","IT","Programmer")
joy=Employee("Joy","Rogers","212-555-9753","81774","Operations","Engineer")

print(susan.printEmp())
print(mark.printEmp())
print(joy.printEmp())

Output ::

File Edit View Navigate Code Refactor Run Iools VCS Window Help ーBeginner ilPerson.py Inheritance.py Person.py Person Phone (

Add a comment
Know the answer?
Add Answer to:
Design and write a class named Employee that inherits the Person class from the previous exercise...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Write a C++ program Write a class named Employee that has the following member variables: name...

    Write a C++ program Write a class named Employee that has the following member variables: name A string that holds the employee name idNumber An int to hold employee id number department A string to hold the name of the department position A string to hold the job position The class will have three constructors: 1. A constructor that accepts all the internal data such as: Employee susan("Susan Meyers", 47899, "Accounting", "Vice President"); 2. A constructor that accepts some of...

  • Create a C# Console program. Add a class named Employee that has the following public fields:...

    Create a C# Console program. Add a class named Employee that has the following public fields: • Name. The name field references a String object that holds the employee’s name. • IDNumber. The IDNumber is an int that holds the employee’s ID number. • Department. The department field is a String that holds the name of the department where the employee works. • Position. The position field is a String that holds the employee’s job title. Once you have written...

  • Using C++, Write a class named Employee that has the following member variables: name. A string...

    Using C++, Write a class named Employee that has the following member variables: name. A string that holds the employee's name. idNumber. An int variable that holds the employee's ID number. department. A string that holds the name of the department where the employee works. position. A string that holds the employee's job title. The class should have the following constructors: A constructor that accepts the following values as arguments and assigns them to the appropriate member variables: employee's name,...

  • Create a c++ code and answer number 1 Homework Ch. 13 - Employee Class 30 points...

    Create a c++ code and answer number 1 Homework Ch. 13 - Employee Class 30 points Design a class named Employee that has the following attributes: * Name ID Number- (Employee's] Identification Number " Department-the name of the department where the employee works " Position-the employee's job title The class should have the following constructors: A constructor that accepts values for all the member data as arguments A constructor that accepts the following values as arguments and assigns them to...

  • It must be C++ Chapter 13 Programming Challenge 2: Employee Class. See instruction: Chapter 13 Programming...

    It must be C++ Chapter 13 Programming Challenge 2: Employee Class. See instruction: Chapter 13 Programming Challenge 2 Employee Class.pdf Program Template: // Chapter 13, Programming Challenge 2: Employee Class #include <iostream> #include <string> using namespace std; // Employee Class Declaration class Employee { private: string name; // Employee's name int idNumber; // ID number string department; // Department name string position; // Employee's position public: // TODO: Constructors // TODO: Accessors // TODO: Mutators }; // Constructor #1 Employee::Employee(string...

  • 1. Write a class named Employee that holds the following data about an employee in attributes:...

    1. Write a class named Employee that holds the following data about an employee in attributes: name, ID number, department, and job title. (employee.py) 2. Create a UML diagram for Employee class. (word file) 3. Create a program that stores Employee objects in a dictionary. Use the employee ID number as the key. (employee_App.py) The program should present a menu that lets the user perform the following actions: ✓ Look up an employee in the dictionary ✔ Add a new...

  • Define a class named Employee . Derive this class from the class Person. An employee record...

    Define a class named Employee . Derive this class from the class Person. An employee record inherits an employee's name from the class Person. In addition, an employee record contains an annual salary (represented by a single value of type double), a hire date that gives the year hired (as a single value of type int), an identification number of type int, and a department of type String. Give your class a reasonable complement of constructors, accessors, mutators, an equals...

  • Create a date class with attributes of month, day, and year. Create an employee class for...

    Create a date class with attributes of month, day, and year. Create an employee class for storing information related to employee information for the CS1C Corporation. This class should contain the employee’s name, employee’s Id, phone number, age, gender, job title, salary, and hire date. You should write a series of member functions that change the employee’s name, employee’s Id, phone number, age, job title, salary, and hire date. You should use your date class (composition) when accessing hire date....

  • E2a: Create a class called Employee that includes three pieces of information as data members---a first...

    E2a: Create a class called Employee that includes three pieces of information as data members---a first name (char array), last name (char array) and a monthly salary (integer). Your class should have a constructor that initializes the three data members. If the monthly salary is not positive, set it to 0. Write a test program that demonstrates class Employee’s capabilities. Create two Employee objects and display each object’s yearly salary. Then give each Employee a 10 percent raise and display...

  • a c++ program (The Person, Student, Employee, Faculty, and Staff classes) Design a class named Person...

    a c++ program (The Person, Student, Employee, Faculty, and Staff classes) Design a class named Person and its two subclasses named Student and Employee. Make Faculty and Staff subclasses of Employee. A person has a name, address, phone number, and email address. A student has a class status (freshman, sophomore, junior, or senior). Define the status as a constant. An employee has an office, salary, and date hired. Use the MyDate classto create an object for date hired. A faculty...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT