Ask your own question, for FREE!
Computer Science 16 Online
OpenStudy (anonymous):

While Leafing through Internet sites i found this program, any one can help me to solve it by Java ? http://csee.wvu.edu/~abrady/cs110/docs/cs110-hw7.pdf

OpenStudy (anonymous):

So it uses the abstract class Worker public abstract class Worker { private String name; private int hoursWorked; private double hourlyRate; public Worker(String name, int hoursWorked, double hourlyRate) { setName(name); setHoursWorked(hoursWorked); setHourlyRate(hourlyRate); } protected final String getName() { return name; } private final void setName(String name) { this.name = name; } protected final int getHoursWorked() { return hoursWorked; } private final void setHoursWorked(int hoursWorked) { this.hoursWorked = hoursWorked; } protected final double getHourlyRate() { return hourlyRate; } private final void setHourlyRate(double hourlyRate) { this.hourlyRate = hourlyRate; } protected abstract double getWages(); }

OpenStudy (anonymous):

and payroll.txt which is as follows: Salaried,Wilson,40,6.87 Temporary,Jones,27,4.5 Hourly,Smith,45,5.55 Salaried,Miller,30,7.33 Hourly,Walker,55,5.5 Salaried,Turner,45,8.24 Hourly,Best,35,7.99 Temporary,Johnson,8,4.99 Hourly,Struthers,42,6.49 Hourly,Monson,40,5.99

OpenStudy (anonymous):

So first let's examine the Worker class: So you have an interface class called worker, with 3 variables (name, hoursWorked, hourlyRate), a constructor method (called Worker), and 6 other methods (getter/setter methods). And finally there is an abstract method (an interface) called getWages(). A Protected method can only be called within the inheritance hierarchy. Public methods can be called from anywhere.

OpenStudy (anonymous):

Next, you are given the following INSTRUCTIONS: Write a program to model three different kinds of employees in a company using inheritance and File I/O. Your program will consist of three classes that extend the class Worker and a testing class Company that reads in payroll information from a file then prints it to the screen. The Classes SalariedWorker, HourlyWorker, and TemporaryWorker: To model employees, extend the provided abstract class Worker by writing three new classes: SalariedWorker,HourlyWorker, and TemporaryWorker. //program to model three different kinds of employees public class SalariedWorker extends Worker { } public class HourlyWorker extends Worker{ } public class TemporaryWorker extends Worker{ }

OpenStudy (anonymous):

You are given the following instructions for a Company class: Your program will consist of ...a testing class Company that reads in payroll information from a file then prints it to the screen. so we need a new class called company //new Company class public class Company{ //your method to read in payroll info from a file and print it to the screen will go here } Next you are told: Create a class called Company with a main method to test your classes. So, slight alteration to the above: //new Company class public class Company{ //main method public static void main(String[] args){ //code to read in payroll info from a file and print it to the screen will go here } }

OpenStudy (anonymous):

Now it says: " Implement the abstract methods as required." So here, they are talking about the getter setter methods from the Worker interface class I mentioned before. Another important thing they say is: "only write methods that override methods from either Worker or Object." which allows you to over-ride the methods in the Worker class.

Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!
Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!