The Artima Developer Community
Sponsored Link

Java Answers Forum
solve this problem for me (urgently needed)

1 reply on 1 page. Most recent reply: Feb 8, 2003 3:13 PM by Max Lyn

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 1 reply on 1 page
tiro john

Posts: 6
Nickname: motiero
Registered: Feb, 2003

solve this problem for me (urgently needed) Posted: Feb 6, 2003 11:12 AM
Reply to this message Reply
Advertisement
, DEPARTMENT OF COMPUTER SCIENCE

CSI342: DATA STRUCTURE AND DATA ABASTRACTION

Create a Java class Employee that will describe the characteristics of the employees of a company. This class should contain the name (first and last name), omang, address, etc of the employee, together with pay information. Given that this company has two different types of employees, those on a salary and those paid by the hour. Create two subclasses of Employee: SalariedEmployee and HourlyEmployee, with different methods for calculating monthly pay and for displaying an employee details. Both of these subclasses should inherit all of the common information and methods from Employee, but should override the methods used to calculate pay and to display employee details.

Possible specifications for Employee, SalariedEmployee and HourlyEmployee classes are given below:

Class ? Employee
Instance Variables ? firstName, lastName, address, omang, pay
Constructors ? Employee() // all Strings to null, pay=0? Employee(first, last, id) // Initializes with values, pay=0
Methods ? setName (first, last)? setOmag(id)? get FirstName()? get lastName()? getOmang()? toString()? calcPay (value)


Class ? SalariedEmployee extends Employee
Instance Variables ? salary
Constructors ? SalariedEmployee() // salary=0? Employee(first, last, id, sal) // Initializes with values
Methods ? setSalary(sal)? toString()? calcPay (sal) //returns pay(i.e. salary)






Class ? HourlyEmployee extends Employee
Instance Variables ? rate
Constructors ? HourlyEmployee() // rate=0? Employee(first, last, id, rateVal) // Initializes with values
Methods ? setRate(rateVal)? toString()? calcPay (hours) // returns pay (rate*hours)

Write a Java class to test access to objects of class HourlyEmployee and SalariedEmployee using references to the respective subclasses.


Max Lyn

Posts: 11
Nickname: techrolla
Registered: Feb, 2003

Re: solve this problem for me (urgently needed) Posted: Feb 8, 2003 3:13 PM
Reply to this message Reply
you shoudl first make an Employee class or maybe an employee interface that just has methods with out a body, then make the two subclasses and just implement the methods for each diferent employee. Like,

class Employee {
final static int HOURLY_PAY = 0;
final static int YEARLY_PAY = 1;

String getPayType(int id);
int getPay(Employee e);
String getName(int id)
{
return name;
}
}

class SalariedEmployee extends Employee {

void getPayType(int payType)
{
if(payType == YEARLY_PAY)
return "salaried";
}

Flat View: This topic has 1 reply on 1 page
Topic: Need help with comm service programming Please help Previous Topic   Next Topic Topic: what is ODBC admin tool...

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use