Sl

Fermé
aymenboy Messages postés 8 Date d'inscription mardi 22 décembre 2009 Statut Membre Dernière intervention 30 mars 2010 - 4 janv. 2010 à 14:59
cs_DARKSIDIOUS Messages postés 15814 Date d'inscription jeudi 8 août 2002 Statut Membre Dernière intervention 4 mars 2013 - 4 janv. 2010 à 15:27
slt je besoin de m'aider à mon projet je veut que tu me corrige mes faute s'il te plait bon le projet est :

une compagnie aérienne offre un service de reservavtion accessible à distance chaque vol est défini par son numero (identifiant unique ),pays de départ ,pays destination ,heure , nombre de place non encore réservéés et prix du tiket
le service offre trois opérations
1_reserver : à paritr d'un nom de client , un numero de vol et d'une date . cette opération renvois un entier qui correspond au numero du ticket si réservation réussie ou -1 sinon
2_annuler à partir d'un numero de vol et un tiket cette opération annule la réseravation corespondante .elle retourne 1 si annulation réussie ,0 si paramétre d'entréé non valides
3_ lister à partir d'une date , de pays départ et destination ,cette opération rend les numéros et les horaires ainsi que le prix de ticket des vols corresondant à ces paramétres de recherche


question :
réaliset en java RMI une implémentation du systéme décrit ci-dessus



et voila le code que je l'écris pour le client dabor :

public interface AgenceInterface extends java.rmi.Remote {

public int[] reserver(String nomClient,int numVol,String dateV,String NomHotel,String dateH,int nbChambre) throws java.rmi.RemoteException;

public int annuler(int numVol,int numTicket,int numReservation) throws java.rmi.RemoteException;

public String[] listerV(String date ,String paysDepart,String paysDestination) throws java.rmi.RemoteException;

public String[] listerH(int numReservation) throws java.rmi.RemoteException;

}


pour le serveur :




public class AgenceServeur extends UnicastRemoteObject implements AgenceInterface {


Connection cn;
Statement st;


public AgenceServeur() throws java.rmi.RemoteException { }

public int[] reserver(String nomClient,int numVol,String dateV,String nomHotel,String dateH,int nbChambre) throws java.rmi.RemoteException {

int numTicket=-1;
int numReservation=-1;
int reservation[]={numTicket,numReservation};
try{
InterfaceVol obj = (InterfaceVol) Naming.lookup ("rmi://localhost:1099/volServeur");
numTicket = obj.reserverV(nomClient,numVol,dateV);
InterfaceHotel obj1 = (InterfaceHotel) Naming.lookup ("rmi://localhost:1099/hotelServeur");
numReservation = obj1.reserverH(nomClient,nomHotel,dateH,nbChambre);
reservation[0]=numTicket;
reservation[1]=numReservation;


}

catch (SQLException ex) {
System.out.println(ex.getMessage());

return reservation;
}

catch (ClassNotFoundException ex) {


return reservation;
}
catch (NotBoundException ex) {
System.out.println("Erreur NotBoundException");


return reservation;
}

catch (MalformedURLException ex) {
System.out.println("Erreur MalformedURLException");


return reservation;
}

catch (RemoteException ex) {
System.out.println("Erreur RemoteException");

return reservation;
}

}

public int annuler(int numVol,int numTicket,int numReservation) throws java.rmi.RemoteException {

int testVol;
int testHotel;
try{
InterfaceVol obj = (InterfaceVol) Naming.lookup ("rmi://localhost:1099/volServeur");
testVol = obj.annulerV(numVol,numTicket);
InterfaceHotel obj1 = (InterfaceHotel) Naming.lookup ("rmi://localhost:1099/hotelServeur");
testHotel = obj1.annulerH(numReservation);


return(1);
}

else
return(0);

}

catch (SQLException ex) {


return(0);
}

catch (ClassNotFoundException ex) {


return(0);
}
catch (NotBoundException ex) {


return(0);
}

catch (MalformedURLException ex) {


return(0);
}

catch (RemoteException ex) {


return(0);
}


}

public String[] listerV(String date ,String paysDepart,String paysDestination) throws java.rmi.RemoteException {

String[] rs={" "," "," "} ;

try{
InterfaceVol obj = (InterfaceVol) Naming.lookup ("rmi://localhost:1099/volServeur");
rs = obj.listerV(date,paysDepart,paysDestination);

}
/*
catch (SQLException ex) {
System.out.println("Erreur Sql");
rs = null;
}
*/

catch (NotBoundException ex) {
System.out.println("Erreur NotBoundException");
rs=null;
}

catch (RemoteException ex) {
System.out.println("Erreur RemoteException");
rs=null;
}
catch (MalformedURLException ex) {
System.out.println("Erreur MalformedURLException");
rs=null;;
}

return(rs);
}//fin listerV()

public String[] listerH(int numReservation) throws java.rmi.RemoteException {

String info="Reservation introuvable";
String s[];
try{
InterfaceHotel obj = (InterfaceHotel) Naming.lookup ("rmi://localhost:1099/hotelServeur");
s = obj.listerH(numReservation);
}

catch (NotBoundException ex) {

s=null;
}

catch (RemoteException ex) {

s= null ;
}
catch (MalformedURLException ex) {

s=null;
}

return(s) ;
}

public static void main(String args[]) throws IOException {


try{

AgenceServeur monServeur = new AgenceServeur();

Naming.rebind("rmi://localhost:1099/AgenceServeur", monServeur);

}

catch (RemoteException e) {
System.out.println("AgenceServeur err: " + e.getMessage());
}
}

}

1 réponse

cs_DARKSIDIOUS Messages postés 15814 Date d'inscription jeudi 8 août 2002 Statut Membre Dernière intervention 4 mars 2013 130
4 janv. 2010 à 15:27
Salut,

Pas besoin de flooder le forum, attends d'avoir une réponse à ton message précédent (si tu as une réponse).

Sujet clos !
______________________________________
DarK Sidious
0
Rejoignez-nous