Question
In Java please. I'm looking for examples on how the classes and constructors flow together to compare against mine. //////////////////////////////////////// Background: Topics: - Inheritance -
In Java please. I'm looking for examples on how the classes and constructors flow together to compare against mine.
////////////////////////////////////////
Background:
Topics:
- Inheritance - Super/Base - ArraysList (Java) / List (C#) - Static variables/methods - ToString Override
For this assignment, you will code a portion of a basic payroll management system
Your task:
For this assignment, you will implement the Employee and Faculty classes, utilizing the fundamentals of inheritance and ArrayLists (Java) / Lists (C#).
Define the following two classes:
1) Employee Class
a) Must have the following attributes:
- Name, string, private, employees full name
- Employee ID, int, private, unique employee id
- Number of employees, int, private, static, initialized with zero (0), ongoing number of objects created (incremented each time an object is created)
b) Must have a default constructor which:
- assigns a default value of new employee to the name attribute
- assigns the value of ++numberOfEmployees to the employee id attribute (i.e. the creation of each object increments the numberOfEmployees attribute, which is assigned to the employee id attributes)
c) Must have an overloaded constructor which:
- takes in a single parameter of type string and assigns it to the name attribute
- assigns the value of ++numberOfEmployees to the employee id attribute (i.e. the creation of each object increments the numberOfEmployees attribute, which is assigned to the employee id attributes)
d) Must have getter/setter methods for the name and employee id attributes
e) Must have a static method called getNumberOfEmployees, which returns the value of the static attribute numberOfEmployees
f) Must have a static method called decreaseNumberOfEmployees, which returns no value, takes in no parameters, and decrements the static attribute numberOfEmployees by one (1) (i.e. numberOfEmployees --)
2) Faculty Class
a) The Faculty class inherits the Employee class
b) Must have the following attributes:
- Weekly salary: double, private, a faculty members weekly salary amount
- Weekly stipend: double, private, a faculty members weekly stipend amount
- Weekly pay: double, private, a faculty members total weekly pay amount
c) Must have an overloaded constructor which:
- takes in a parameter of type string and calls the default constructor in Employee class to assign the parameter value to the name attribute in the Employee class - takes in a parameter of type double and assigns it to the weekly salary attribute
- takes in a parameter of type double and assigns it to the weekly stipend attribute
d) Must have getter/setter methods for the weekly salary, weekly stipend, and weekly pay attributes
e) Must have a public method called calculateWeeklyPay, which takes in no parameters, returns no values, and calculate the weekly pay amount (i.e. weeklySalary + weeklyStipend) and assigns it to the weekly pay attribute.
f) Must override the tostring method to return a string which includes the label and value of all attributes (i.e. name, weekly salary, weekly stipend, weekly pay)
Driver Program:
In the driver class:
- Create an ArrayList (Java) / List (C#) of Faculty objects.
- Create a method addFaculty, which returns no values and takes in one (1) parameter, an arrayList (Java) / List (C#) of Faculty objects:
prompt the user to enter and read in a name
prompt the user to enter and read in a weekly salary
prompt the user to enter and read in a weekly stipend
use the name, weekly salary, and weekly stipend to create a Faculty object and store the object into the arrayList (Java) / List (C#) - Create a method removeFaculty, which returns no values and takes in one (1) parameter, an arrayList (Java) / List (C#) of Faculty objects:
prompt the user to enter and read in a name
search the arrayList (Java) / List (C#) for the object containing the user provided name
if the object is found, remove the object from the arrayList (Java) / List (C#), update the numberOfEmployees attribute, and end the search
- Create a method calculateFacultyPay, which returns no values and takes in one (1) parameter, an arrayList (Java) / List (C#) of Faculty objects:
Traverse the entire arrayList (Java) / List (C#)
For each object in the arrayList (Java) / List (C#), invoke the calculateWeeklyPay method to compute the weekly pay for the faculty member.
- Create a method printFaculty, which returns no values and takes in one (1) parameter, an arrayList (Java) / List (C#) of Faculty objects:
Traverse the entire arrayList (Java) / List (C#)
For each object in the arrayList (Java) / List (C#), print the object
- Using a loop, prompt the user with the following menu and read in the users response:
1 Add Faculty 2 Delete Faculty 3 Calculate Faculty Pay 4 Print Faculty 5 Exit Enter Choice:
If the user enters 1, invoke the method addFaculty
If the user enters 2, invoke the method deleteFaculty
If the user enters 3, invoke the method calculateFacultyPay
If the user enters 4, invoke the method printFaculty
If the user enters 5, terminate the program
If the user enters any character other than a 1, 2, 3, 4, or 5, the following error message should display: Error: Please enter valid input, and the user should be allowed to reenter a valid choice.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started