Hi everyone, 

I agree with Steve, operator overloading is strictly speaking not native to JAVA (I know of it only in C++ and perhaps SmallTalk ).

You can however mimic it in JAVA in the following way, lets say you have two Employee objects emp1 and emp2; 

This is done with the assumption that you have an Employee class with a definition similar to the one below: 

Disclaimer: I have not run the program below through a compiler to check for syntax and errors in logic:

public class Employee {
// Properties of the class
    String employeeID, name;
Double salary, allowance;
// Constructor for the class 
public Employee ( String employeeId, String employeeName)
{
setEmployeeID( employeeId );
setEmployeeName( employeeName );
} // End class Employee 
// Setter methods 
public void setEmployeeID( String employeeId ) 
{
this.employeeID = employeeId;
} // End method setEmployeeID 
public void setEmployeeName( String employeeName ) 
{
this.employeeName = employeeName;
} // End method setEmployeeID 
public void setSalary( double basicPay ) 
{
this.salary = basicPay;
} // End method setSalary 
public void setAllowance( double allowance ) 
{
this.allowance = allowance;
} // End method setAllowance 
// Getter methods 
public double computeGrossSalary ( ) 
{
return this.salary + this.allowance; 
} // End method computeGrossSalary
// Continue with the rest for names, id, salary and allowances 
// A method for comparing two employees' earnings
public boolean equalsTo ( Employee compared )
{
return this.computeGrossSalary ( ) == compared.computeGrossSalary ( );
// Convert the employee object to string
public String toString ( )
{
return "My name is "+getEmployeeName( )+". My gross salary is "+computeGrossSalary ( ) ;
} // End metho toString

} //End class Employee 

@Gatekeeper, I hope that helps and the student was able to get a correct solution on time? 

Martin.

On Tue, Apr 3, 2012 at 6:48 PM, Gate Keeper <mohasq@gmail.com> wrote:
Skunks
I will ask the student to get the Lecturers answer then we see what he/she had as the answer.
_______________________________________________
Skunkworks mailing list
Skunkworks@lists.my.co.ke
------------
List info, subscribe/unsubscribe
http://lists.my.co.ke/cgi-bin/mailman/listinfo/skunkworks
------------

Skunkworks Rules
http://my.co.ke/phpbb/viewtopic.php?f=24&t=94
------------
Other services @ http://my.co.ke