It sounds to me like you need to create an employee class which has getters and setters for name, department and computer. So
public class Employee {
private String name;
private Computer computer;
// constructor
public Employee (String newName, Computer newComputer) {
setName(newName);
setComputer(newComputer);
};
// getter methods
public String getName(){ return name; };
public String getComputer() { return computer;}
// setter methods
public void setName(String newName) {name = newName;}
//etc.
}
You'll also want to write a Computer class, with getters and setters for the serial number.
You'll want to use these classes (when you've finished them off) from another class which has a collection of Employees and a collection of Computers - your Department class. Here's a snippet to help you with that:
int max=4; //max number of employees
Employee Emp[]=new Employee[max]; // array, size max of
//Employee objects
// loop through Emp array and instantiate
// each employee object contained in it.
for(int i=0;i<max;i++) {
String employeeName = "Employee #" + i; // replace with a sensible name!
String serialNumber = "Computer #" + i;
Emp[i]=new Employee(employeeName,new Computer(serialNumber));
}
Also give this a hasEmployee method, which returns true if an Employee is in your Emp[] Array. It'll also want a howManyComputers() method which will tell you how many computers the department has (the size of your computers array).
Finally, you'll want an Organization class, which has a collection of Departments and a main method which instantiates everything.
HTH charlie
--
Don't Stand on your head - you'll get footprints in your hair
http://charlieharvey.org.uk
http://charlieharvey.com