Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Class Relationships: Inheritance LAB In this lab you will derive a new class called Employee from the Person class. The Employee class will have an

Class Relationships: Inheritance

LAB

In this lab you will derive a new class called Employee from the Person class. The Employee class will have an EmployeeNo and a MonthlySalary property. You will then create a new program called EmployeeProgram that manipulates an array of Employees in much the same way you manipulated Person objects in the previous labs.

Step 1

Create an Employee class. Here are the associated UML diagrams for your reference:

Class Relationships:

Class Diagram:

Employee

  • employeeNo : int
  • monthlySalary : float
  • hireDate : Date

+ Employee(firstName : String , lastName : String, middleInit : char,

birthDate : Date, employeeNo : int,

monthlySalary : float, hireDate : Date)

+ Employee()

+ setEmployeeNo( employeeNo : int)

+ getEmployeeNo() : int

+ setMonthlySalary( monthlySalary : float)

+ getMonthlySalary() : float

+ setHireDate( hireDate : Date)

+ getHireDate() : Date

+ toString(): String

Step 2

* Have the instructor check your Employee class to ensure it is correct before proceeding.

Now create a modified version of your PersonProgram called EmployeeProgram. This program should leverage much of the extended Person code inherited by the Employee class. It will have the following modifications:

  1. It will use an array of Employee objects called employees, declared like this:

static Employee[] employees;

later when you create an instance of the array you will use:

employees = new Employee[5];

And create an instance of Employee in each cell of the employees array with a line like:

employees[0] = new Employee("John", "Smith", 'T',

new Date(6,24,80),

100101, 2789.0f, new

Date(5,22,2000);

  1. The main menu will now have the following options:

1. Display all employees

2. Display info for employee by list number

3. Display info for employee by employee number

4. Edit info for employee by employee number

5. Exit

  1. Display all Employees will list employees in the following format:

  1. employeeNo : lastName, fisrtName middleInit.

  1. Display info for employee by list number displays an employee by their position in the array. This is the same as it was in the person program, but includes employee number and monthly salary in the output.
  2. Display info for employee by employee number prompts the user for an employee number, and searches the array for an employee with that employee number. If one is found it is displayed, if not a record not found message is printed to the screen.
  3. Edit info for employee by employee number prompts the user for an employee number, and searches the array for an employee with that employee number. If one is found, its name is displayed along with the modified sub menu from the PersonProgram:
  1. Employee Number
  2. First Name
  3. Last Name
  4. Middle Init
  5. Monthly Salary
  6. Birth Date
  7. Hire Date
  8. Exit

Other than the search by employee feature, and the additional fields this is the same as the person program.

image text in transcribedimage text in transcribed

4. Display info for employee by list number displays an employee by their position in the array. This is the same as it was in the person program but includes employee number and monthly salary in the output. 5. Display info for employee by employee number prompts the user for an employee number, and searches the array for an employee with that employee number. If one is found it is displayed, if not a 'record not found" message is printed to the screen. 6. Edit info for employee by employee number prompts the user for an employee number, and searches the array for an employee with that employee number. If one is found, its name is displayed along with the modified sub menu from the Person Program: 1. Employee Number 2. First Name 3. Last Name 4. Middle Init 5. Monthly Salary 6. Birth Date 7. Hire Date 8. Exit Other than the search by employee feature, and the additional fields this is the same as the person program. Class Diagram: Employee employeeNe_int monthly Salary float biceDate_Date + Employee(firstName : String, lastName: String, middlelnit : char, bidhDate: Date, employeeNo: int, moothlySalary: float, biceDate: Date) + Employee) + selEmploveelal employeedo: int) +getEmployeele: int + setMonthly Salaryl_monthly Salary: float) + getMonthly Salary!): float + set HiceDateLhiteDate : Date) + getHire Datel): Date + toStng): String Step 2 Have the instructor check your Employee class to ensure it is correct before proceeding. Now create a modified version of your person Preacam called Employee Program. This program should leverage much of the extended Person code inherited by the Employee class. It will have the following modifications: 1. It will use an array of Employee objects called employees, declared like this

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Practical Database Programming With Visual C# .NET

Authors: Ying Bai

1st Edition

0470467274, 978-0470467275

More Books

Students also viewed these Databases questions

Question

2 What are the implications for logistics strategy?

Answered: 1 week ago