Question

*Python* INTRODUCTION: The goal of this programming assignment is to enable the student to practice object-oriented...

*Python*

INTRODUCTION:

The goal of this programming assignment is to enable the student to practice object-oriented programming using classes to create objects.

PROBLEM DEFINITION:

Write a class named Employee that holds the following data about an employee in attributes: name, IDnumber, department, jobTitle

The class should have 8 methods as follows:

 For each attribute, there should be a method that takes a parameter to be assigned to the attribute. This is known as a mutator method.

 For each attribute, there should be a method that returns the attribute. This is known as an accessor or getter method.

Once you have written the class, define a main function that first defines an empty list. Example: personnelList = [ ]

Next, in the main function should be a loop that repeats at least three times. In the loop, define an object using the Employee class. After defining the object, still in the loop, do the following:

a. Display a message asking user to enter employee name, ID, department, and title

b. Read employee_name into a variable

c. Call the mutator method for the name attribute of the object passing the employee_name

d. Read employee_ID into a variable

e. Call the mutator method for the IDnumber attribute of the object passing employee_ID

f. Read employee_department into a variable

g. Call the mutator method for the department attribute of the object passing the employee_department

h. Read employee_title into a variable

i. Call the mutator method for the jobTitle attribute of the object passing the employee_title

j. Append the object to the list

Next, still in the main function, display three heading lines. After the print() statements that displays the heading lines, still in the main function, write another loop. This second loop should go through the list one element per loop iteration (pass). In this second loop, write statements that call the accessor methods of the list element and display the values returned by the accessor methods. After and outside the main function, write a statement to call the main() function.

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

class Employee:
        def getName(self):
                return self.name
        def getIDnumber(self):
                return self.IDnumber
        def getDepartment(self):
                return self.department
        def getJobTitle(self):
                return self.jobTitle

        def setName(self, name):
                self.name = name
        def setIDnumber(self, IDnumber):
                self.IDnumber = IDnumber
        def setDepartment(self, department):
                self.department = department
        def setJobTitle(self, jobTitle):
                self.jobTitle = jobTitle

def main():
        personnelList = [ ]

        for _ in range(3):
                e = Employee()
                employee_name = input('Enter employee name: ')
                e.setName(employee_name)
                employee_ID = input('Enter employee id: ')
                e.setIDnumber(employee_ID)
                employee_department = input('Enter employee department: ')
                e.setDepartment(employee_department)
                employee_title = input('Enter employee job title: ')
                e.setJobTitle(employee_title)
                
                personnelList.append(e)


        print('%10s%10s%10s%10s' % ('Name', 'IDnumber', 'Department', 'JobTitle'))
        for p in personnelList:
                print('%10s%10s%10s%10s' % (p.getName(), p.getIDnumber(), p.getDepartment(), p.getJobTitle()))

main()


Please upvote, as i have given the exact answer as asked in question. Still in case of any issues in code, let me know in comments. Thanks!
Add a comment
Know the answer?
Add Answer to:
*Python* INTRODUCTION: The goal of this programming assignment is to enable the student to practice object-oriented...
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
  • Create the Python code for a program adhering to the following specifications. Write an Employee class...

    Create the Python code for a program adhering to the following specifications. Write an Employee class that keeps data attributes for the following pieces of information: - Employee Name (a string) - Employee Number (a string) Make sure to create all the accessor, mutator, and __str__ methods for the object. Next, write a class named ProductionWorker that is a subclass of the Employee class. The ProductionWorker class should keep data attributes for the following information: - Shift number (an integer,...

  • Programming Assignment 6: Object Oriented Programming Due date: Check Syllabus and Canvas Objectives: After successfully completing...

    Programming Assignment 6: Object Oriented Programming Due date: Check Syllabus and Canvas Objectives: After successfully completing this assignment, students will practice Object Oriented design and programming by creating a Java program that will implement Object Oriented basic concepts. RetailItem Class: Part 1: Write a class named RetailItem that holds data about an item in a retail store. The class should have the following fields: • description. The description field references a String object that holds a brief description of the...

  • 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...

  • IN PYTHON Assignment Overview This assignment will give you experience on the use of classes. Understand...

    IN PYTHON Assignment Overview This assignment will give you experience on the use of classes. Understand the Application The assignment is to first create a class calledTripleString.TripleStringwill consist of threeinstance attribute strings as its basic data. It will also contain a few instance methods to support that data. Once defined, we will use it to instantiate TripleString objects that can be used in our main program. TripleString will contain three member strings as its main data: string1, string2, and string3....

  • You will need to first create an object class encapsulating a Trivia Game which INHERITS from...

    You will need to first create an object class encapsulating a Trivia Game which INHERITS from Game. Game is the parent class with the following attributes: description - which is a string write the constructor, accessor, mutator and toString methods. Trivia is the subclass of Game with the additional attributes: 1. trivia game id - integer 2. ultimate prize money - double 3. number of questions that must be answered to win - integer. 4. write the accessor, mutator, constructor,...

  • In 6A, you created an object class encapsulating a Trivia Game which INHERITS from Game. Now...

    In 6A, you created an object class encapsulating a Trivia Game which INHERITS from Game. Now that you have successfully created Trivia objects, you will continue 6B by creating a linked list of trivia objects. Add the linked list code to the Trivia class. Your linked list code should include the following: a TriviaNode class with the attributes: 1. trivia game - Trivia object 2. next- TriviaNode 3. write the constructor, accessor, mutator and toString methods. A TriviaLinkedList Class which...

  • Define a class named Payment that contains an instance variable "paymentAmount" (non-static member variable) of type...

    Define a class named Payment that contains an instance variable "paymentAmount" (non-static member variable) of type double that stores the amount of the payment and appropriate accessor (getPaymentAmount() ) and mutator methods. Also create a method named paymentDetails that outputs an English sentence to describe the amount of the payment. Override toString() method to call the paymentDetails() method to print the contents of payment amount and any other details not included in paymentDetails(). Define a class named CashPayment that is...

  • Please use python Programming Language: Select one of the following topics: Band Character Account Create a...

    Please use python Programming Language: Select one of the following topics: Band Character Account Create a class based on your chosen topic. Make sure to include at least four attributes of varying types, a constructor, getters/setters for each attribute w/input validation, a toString, a static attribute, and a static method. Then, create a function (outside of your class) that connects to a text file which should contain the attributes of several objects. Read the data from the file, use the...

  • python code? 1. Create a class called Person that has 4 attributes, the name, the age,...

    python code? 1. Create a class called Person that has 4 attributes, the name, the age, the weight and the height [5 points] 2. Write 3 methods for this class with the following specifications. a. A constructor for the class which initializes the attributes [2.5 points] b. Displays information about the Person (attributes) [2.5 points] c. Takes a parameter Xage and returns true if the age of the person is older than Xage, false otherwise [5 points] 3. Create another...

  • 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...

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