

Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
An assignment for creating a java program consisting of five related classes based on the uml diagram provided. The assignment requires making all instance variables private, making all classes public, initializing instance variables via constructor calls, and implementing tostring and calcpay methods. The employee class is made abstract, and salaried, waged, and sales classes are derived from it. The objective is to push data into the objects using constructor calls and pull data out using tostring and calcpay methods.
Typology: Lab Reports
1 / 2
This page cannot be seen from the preview
Don't miss anything!


Make all instance variables (i.e., attributes) private
Make all classes public (each class in its own file)
Initialize all instance variables via constructor calls
Each toString method should return a string representation of the calling object; this usually includes all instance variables contained inthe object and in any super classes. The format of the returned string is not important. The toString method should not print or displaythe value of any variables - just concatenate and return them
class Employee (make this class abstract)a.^
calcPay: make this method abstract
class Salarieda.^
calcPay returns
salary / 24
b.
Format is not important
class Wageda.^
calcPay returns
hours * wage
b.
Format is not important
class Salesa.^
calcPay returns the salary plus a commission:
salary / 24 + commission * totSales
. However, salary is a private
variable, how will you solve this problem? b.
Format is not important
Complete the assignment with Lab1.java, which contains main and which is posted with this assignment
together and note that Lab1.java is not needed. (Note that I will be using the posted version of Lab1.java, which implies that you shouldnot make changes to it.) Note that the objective of this assignment is to “push” data into the objects with constructor calls and to “pull” data from the objects usingtoString, calcPay.
-name : String+ Employee(name : String, street : String, city : String)+ toString() : String + calcPay() : double
Employee
-street : String-city : String+Address(street : String, city : String)+toString() : String
Address
-salary : double+Salaried(name : String, street : String, city : String, salary : double)+toString() : String+calcPay() : double
Salaried
-hours : double-wage : double+Waged(name : String, street : String, c ity : String, hours : double, wage : double)+toString() : String+calcPay() : double
Waged
-commission : double-totSales : double+Sales(name : String, street : String, city : String, salary : double, commission : double, totSales : double)+toString() : String+calcPay() : double
Sales