cours0708/A61/FASD/NoeudImpl.java

47 lines
951 B
Java

import java.rmi.Remote;
import java.rmi.RemoteException;
import java.util.*;
import java.rmi.server.UnicastRemoteObject;
public class NoeudImpl extends UnicastRemoteObject implements Noeud {
private String name;
private String pere;
private int nbFils;
private Vector<String> fils;
public NoeudImpl(String n, String p) throws RemoteException {
name = n;
pere = p;
fils = new Vector<String>();
nbFils = 0;
}
public String getPere() throws RemoteException {
return pere;
}
public String getName() throws RemoteException {
return name;
}
public String getFils(int i) throws RemoteException {
return fils.get(i);
}
public void addFils(String n) throws RemoteException {
System.out.println("Message du pere:"+ name + ", Ajout du fils:" + n );
fils.add(n);
nbFils ++;
}
public int getNbFils() throws RemoteException {
return nbFils;
}
public Vector getAllFils() throws RemoteException {
return fils;
}
}