[Solved] Assignment 1: Inheritance and Polymorphism

30 $

File Name: Assignment_1:_Inheritance_and_Polymorphism.zip
File Size: 395.64 KB

SKU: [Solved] Assignment 1: Inheritance and Polymorphism Category: Tag:

Or Upload Your Assignment Here:


5/5 – (6 votes)

In this program, you will create a database of Employees. Each Employee has a name & and ID.Managers must also be part of this database. A manager is an employee as well. However, in addition to managers having all the characteristics of employees, managers also manage employees as subordinates. Therefore, a Manager has a list of Employees he/she manages as well as a count of how many subordinates he/she has.Your application should ask the user for details to maintain the list of employees. For each employee, the program should ask the user for the name and whether or not the employee is a manager.If the user specifies that the employee is a Manager, the program should ask the user how many subordinates he/she manages as well as their names. It should create a Manager object, and within the Manager object, create the subordinate Employees. The program should ask the user for the name of the subordinate employees and store their names with the Employee objects.If the user specifies a Manager, the program should create an Employee object.The new employee, either Manager or regular Employee, should be added to the database of Employees.Finally, the program should print out a list of all employees. However, if an Employee is a Manager, it should also print out a list his/her subordinates Employees.12Sample Output

Project Name: A1Classes: EmployeeSystem, Employee, Manager (Name all your classes and filenames appropriately).• Implement an inheritance relationship between classes Employee and Manger based on the following inheritance structure:• Use auto generation of code where you can!ManagerEmployee23Implement each of the following classes using the UML diagram for details on the class structure and following instructions for details on the logic to be implemented.Put your name, class, etc. on Line 1 of ALL classes.If you want to deviate and implement a slightly different solution, you can do that!EMPLOYEE CLASSEmployee# name: string# id: string+ <<property Name : string+ <<property ID : string+ <<constructor Employee()+ <<constructor Employee(name: string)Purpose: The Employee class abstracts the notion of an Employee.Properties: Implement properties as seen in the UML Class Diagram.Constructors: Implement constructors as seen in the UML Class Diagram.

MANAGER CLASSManager– subordinates: Employee[]– numberOfSubordinates: int+ <<constructor Manager()+ <<constructor Manager(name: string)+ PrintSubordinateList(): void+ AddSubordinate(): EmployeePurpose: A Manager class abstracts the notion of a Manager. An apple is also an Employee.Therefore, the Manager class should inherit from the Employee class.Fields: Maintain fields for variables which you need to access from other methods! You definitely need an array of Employees and a count. Add any more that you need!Constructors: Implement constructors for manager. For the overloaded constructor, be sure to redirect to the overloaded constructor of Student!MethodsAddSubordinate() methodGeneral Method Purpose: This method should add one employee to the subordinates array. So youshould ask the user details about one employee, create a new Employee and add it to the array. Rememberto increment the count of subordinates!PrintSubordinateList() methodGeneral Method Purpose: This method should loop through the subordinates array and print out a list ofall employees’ names.45EMPLOYEESYSTEM CLASSEmployeeSystem– listofEmployees : Employee[]– countOfEmployees: int– RunProgram() : void– AddEmployee() : void– PrintEmployeeList() : void+ Main (args: string[]) : voidPurpose: This is the main program class, where the program starts. Implement a RunProgrammethod (or similar), which starts up your program. Call this method from your Main method.Fields: Maintain fields for variables which you need to access from other methods! You definitely needan array of Employees and count. Add any more that you need!Methods:RunProgram() methodGeneral Method Purpose: Maintain this method as your main method which runs the program. This means that this method should make sure you have an Employee array, start up the welcome street, prompt the user to enter employees as long as the user keeps saying yes, and finally displays a list of allthe employees.AddEmployee() methodGeneral Method Purpose: This method should add one employee to the array. Therefore, you should ask the user details about one employee as well as whether the employee is a manager or not. Depending on the answer, you should create either an Employee object or a Manager object.If the user specifies that the employee is a manager, it should ask the user how many subordinates and you should call the relevant method from the Manager class, however many times as needed.Make sure you add the employee (be it Manager or Employee) to the listOfEmployees and increment thecount! This uses upcasting!DisplayEmployeeList() methodGeneral Method Purpose: This method should loop through the listofEmployees and print out the name of all Employees.If an Employee is a Manager, it should also print out a list of all its subordinates by calling the relevant method from the Manager class. Remember – you will need to use downcasting for this!

Reviews

There are no reviews yet.

Only logged in customers who have purchased this product may leave a review.

Shopping Cart
[Solved] Assignment 1: Inheritance and Polymorphism
30 $