Question
In java, c reate a simple object model of a staff database system. It will allow you to start thinking about objects. You should compile
In java, create a simple object model of a staff database system. It will allow you to start thinking about objects. You should compile and run your application after each step.
a)Create a new project, naming the class DatabaseManager. This will be your driver class and will contain the main method which will run our simple database system.
b) Write a class named Employee that has the following attributes:
firstName, a string which holds the employees first name
lastName, a string which holds the employees surname
idNumber, an integer which holds the employees id
position, a string which holds the position description of the employee.
These fields should be declared as private. For example:
private string firstName;
Create a default constructor for the class which initialises the attributes to default values.
Create appropriate accessor and mutator methods for each of the attributes of the Employee class.
c)In the main() method of the DatabaseManager class, create a new instance of an Employee and assign it to a variable(object reference). Read in the employee information from the user. Use methods of the Employee class.
d)In the main() method of the DatabaseManager class, write code to print the employees details to the console. Use methods of the Employee class. Produce the following output:
Employee first name: Fred
Employee last name: Smith
Id number: 2342089
Position: Accountant
e)Perform validation within the mutator method for the ID number of the Employee. Make sure that the id number is positive. If the ID number is not positive ask the user to re-enter the employee ID.
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