transfering data between classes
This is for an assignment. I have completed all other requirements except for this:
I have four classes
abstract class Employee
class PartTimeEmployee extends Employee
class FullTimeEmployee extends Employee
class Manager extends FullTimeEmployee
Payment contains the main method.
Payment() creates an object array containing all the information about the employees. In my main method, i put this "Payment newPayment = new Payment();" in order to create my array of employees.
The call the Payment() creates an array:
static Employee listEmps = new Employee;
and then populates it with employee data using the set methods defined in the employee classes. eg:
listEmps = new FullTimeEmployee(name, salary, ID.....);
listEmps = new Manager(...);
listEmps = new PartTimeEmployee(...);
Is there a way that I can access and change the array created in Payment() from the Manager class? eg have a method in the Manager class that changes the employee's salary?
I've read through my course notes and textbook and can't find what I'm after... That said, I'm probably being dopey and just missing it all
The easiest way I can think of is that the Manager class has a
constructor/set -method that passes the pointer of the Payment object to
the Manager object(s), that in turn keeps a copy of this pointer.
Then you could either make the listEmps array public or have a getListEmps
method in Payment.
Last edited by sjalle; 07-18-2005 at 06:41 AM.
Sorry. I had a brain fart, and wasn't reading/comphrending my notes properly.
I wasn't calling the method properly in the first place.
Remember kiddies ClassName.methodName("Parameters")
BRAIN FART !!! .... that was a new one !!!
Top DevX Stories
Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL