Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

public class Date { // variables private int year; private int month; private int day; // constructor public Date(int theYear, int theMonth, int theDay) {

image text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribed

public class Date { // variables private int year; private int month; private int day; // constructor public Date(int theYear, int theMonth, int theDay) { setYear(theYear); setMonth(theMonth); setDay(theDay); } // setters public void setYear(int theYear) { year = theYear; } public void setMonth(int theMonth) { // only allow months between 1 and 12 if(theMonth>=1 && theMonth days[month] ){ day = 1; } else { day = theDay; } } public String toString() { String result = ""; result = year+"/"+month+"/"+day; return result; } }

public abstract class Person { //variables private String lastName; private String firstName; private char middleInit; private Date birthDate; //Constructors public Person(){}; public Person(String itsLastName, String itsFirstName, char itsMiddleInit, Date itsBirthDate){ lastName = itsLastName; firstName = itsFirstName; middleInit = itsMiddleInit; birthDate = itsBirthDate; } //getters public String getLastName(){ return lastName; } public String getFirstName(){ return firstName; } public char getMiddleInit(){ return middleInit; } public Date getBirthDate(){ return birthDate; } //setters public void setLastName(String itsLastName){ lastName = itsLastName; } public void setFirstName(String itsFirstName){ firstName = itsFirstName; } public void setMiddleInit(char itsMiddleInit){ middleInit = itsMiddleInit; } public void setBirthDate(Date itsBirthDate){ birthDate = itsBirthDate; } //returns full name in "[firstname], [lastname] [middleinit]." format public String getFullName() { String result = ""; result = firstName+", "+lastName+" "+middleInit+"."; return result; } public abstract String toString(); }

public class Employee extends Person{ int employeeNo; float monthlySalary; Date hireDate; public Employee(String itsfirstName,String itslastName,char itsmiddleInit , Date itsbirthDate ,int itsemployeeNo , float itsmonthlySalary ,Date itshireDate ) { super(itsfirstName,itslastName,itsmiddleInit,itsbirthDate); employeeNo=itsemployeeNo; monthlySalary=itsmonthlySalary; hireDate = itshireDate; } public Employee(){};

public void setEmployeeNo( int itsemployeeNo ){employeeNo=itsemployeeNo;}

public int getEmployeeNo(){ return employeeNo;}

public void setmonthlySalary( float itsmonthlySalary ){monthlySalary=itsmonthlySalary;}

public float getmonthlySalary(){ return monthlySalary;}

public void sethireDate( Date itshireDate ){hireDate=itshireDate;}

public Date gethireDate(){ return hireDate;}

public String toString(){ String result=""; result="Employee No: " +employeeNo + " Full Name " +getFullName()+ " Birth Date " +getBirthDate()+ " Monthly Salary" +monthlySalary ; return result; } }

Can anyone help me in Question -5

  1. 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.
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 Employee Program 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: Person Birth Date Employee Class Diagram: Employee employeeNo: int monthly Salaryfloat hire Date : Date + Employee(firstName : String , lastName : String, middlelnit : char, birth Date: Date, employeeNo: int, monthlySalary: float, bireDate : Date) + Employeel) + setEmployeeNo employeeNe: int) +getEmployeeNod) :int + setMonthly Salary_monthlySalary: float) + getMenthlySalary(): float + set Hire RatelbireDate : Date) + get Hire Datel): 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 Person Program 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: 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); 2. 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 3. Display all Employees will list employees in the following format: a. employeeNo: lastName, fisitName middlelnit. 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

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

Step: 3

blur-text-image

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

Advances In Databases And Information Systems Uropean Conference Adbis 2020 Lyon France August 25 27 2020 Proceedings Lncs 12245

Authors: Jerome Darmont ,Boris Novikov ,Robert Wrembel

1st Edition

3030548317, 978-3030548315

More Books

Students also viewed these Databases questions