import java.rmi.* ;
import java.rmi.RMISecurityManager;
import java.rmi.server.UnicastRemoteObject;

public class CompteServeur 
  extends UnicastRemoteObject
  implements CompteDistant {
   
   float solde = 0;
   // constructeur
   public CompteServeur() throws java.rmi.RemoteException {
   super();
}

public static void main(String args[]) {
//create stub security manager
 System.setSecurityManager(new RMISecurityManager());
 try {
       // instantiate server object
       CompteServeur name = new CompteServeur();

      // bind server name to registry
      Naming.rebind("//Pc139117/gestionCompteDistant", name);
  }
  catch (Exception e) {
    System.out.println("Exception: " + e.getMessage());
    e.printStackTrace();
  }
} 

// depot montant et renvoie le nouveau solde
  public float depot (float montant) 
  throws java.rmi.RemoteException {
     solde += montant;
     return solde;
     
  }

// retrait montant et renvoie le nouveau solde
  public float retrait(float  montant)
  throws java.rmi.RemoteException {
     solde -= montant;
     return solde;
     
  }
  
// renvoie le solde courant
  public float litSolde() 
  throws java.rmi.RemoteException {
    return solde;
  }
}