The topic of the lab today is again java classes, how to create them, how to create the constructors, variables, getters and setters. The program that you must write deals with data about different jobs, such as name, salary, etc. The program must also be able to compare two jobs.
The lab is very similar to Lab 5 and to the lab portion of the first midterm. You are given a driver class, containing the main and you must create another class, in order to make the code in the main work
Preliminary Information:
You must use the following java classes:
Code to get started: Driver.java
Stage 1:
Create a new class named Job and write the constructors for class Job. Don't forget to create a new Eclipse java project before creating the classes Job and Driver.
The constructors should set the values of the variables for the new object to default values, written in the comments in the main after each invocation of the constructors.
Remember the constructor is called when you create a new object or instance of the class, that is when you
use the
operator new. The constructor is basically just an initializer for the new object.
Stage 2:
The invocation of the methods displayHourlyRate and compareTo inside the driver code in the main must work correctly. You need to create those methods in the class Driver.
Stage 3 (Advanced):
The code of the main of the first two stages creates 4 instances of the class Job, each representing a different job. In stage 3 you must uncomment the line // displayInOrder( job1, job2, job3, job4); and implement the method displayInOrder that prints out the 4 jobs by best hourly rate first. The declaration of the method has already been provided, you just need to write code inside.