Package profil

Examples of profil.Profil


  public static void main(String[] args) {
    String login = null;
    String pass = null;
   
    boolean ok = false;
    Profil profil = null;
   
    InputStreamReader lecteur = new InputStreamReader(System.in);
    BufferedReader in = new BufferedReader(lecteur);
   
    try {
      new Serveur();
     
      while (!ok) {
        System.out.print("Login : ");
        login = in.readLine();
 
        System.out.print("Mot de passe : ");
        pass = in.readLine();
       
        try {
          profil = Client.connexion(login, pass);
         
          if (profil == null) {
            System.err.println("Une erreur est survenue durant la tentative de connexion, veuillez réessayer ultérieurement");
          } else {
            System.out.print("Bienvenue ");
            System.out.println(profil.getPrenom() + " " + profil.getNom());
            ok = true;
          }
        } catch (ProfilException e) {
          System.err.println(e.getMessage());
        }
View Full Code Here


 
  /* ---------- Profils ---------- */
 
  @Override
  public Profil connexion(String login, String password) throws RemoteException, ProfilException {
    Profil profil = null;
   
    try {
      // Récupération de la liste des profils
      HashMap<String, Profil> profils = Serialiser.deserialiser(Constantes.PROFIL);
      profil = profils.get(login);
    } catch (IOException e) {
      throw new ProfilException(ProfilException.INVALID_USERNAME);
    }

    // Si le profil n'existe pas, on retourne null
    if (profil == null) {
      System.out.println("Echec de la connexion pour l'utilisateur " + login + " : profil inexistant");
      throw new ProfilException(ProfilException.INVALID_USERNAME);
    }
   
    // Si la combinaison login/mot de passe est correcte, on retourne le profil correspondant
    if (profil.getPassword().equals(password)) {
      System.out.println(login + " vient de se connecter");
      return profil;
    }
   
    // Si le profil existe mais que le mot de passe st incorrect pour ce profil, on retourne null
View Full Code Here

      return false;
    }

    try {
      // Récupération du profil des deux utilisateurs
      Profil profil1 = profils.get(pseudo);
      Profil profil2 = profils.get(ami);
     
      // Les utilisateurs deviennent réciproquement "amis"
      // S'ils le sont déja -> Retour faux
      if (profil1.getAmi(ami) == null)
        profil1.ajouterAmi(ami);
      else
        return false;
     
      if (profil2.getAmi(pseudo) == null)
        profil2.ajouterAmi(pseudo);
      else
        return false;
     
      // Enregistrement des modifications apportées au profil
      profils.put(pseudo, profil1);
View Full Code Here

  public static void main(String[] args) {
    File f = new File(Constantes.PROFIL);
    f.delete();
   
    try {
      Client.newProfil(new Profil("tarek.tarek13", "azerty", "JAOUANI", "Tarek", Sexe.H));
      Client.newProfil(new Profil("kevkev69", "azerty", "FRANCES", "Kévin", Sexe.H));
      Client.newProfil(new Profil("dalleria", "azerty", "DALLE-RIVE", "Antoine", Sexe.H));
      Client.newProfil(new Profil("calleay", "azerty", "CALLEA", "Yohann", Sexe.H));
      Client.newProfil(new Profil("bab", "azerty", "CISSE", "Babacar", Sexe.H));
      Client.newProfil(new Profil("aitmachin", "azerty", "AIT-MAMA", "Meryeme", Sexe.F));
    } catch (IOException e) {
      System.err.println("Une erreur est survenue durant la création d'un profil.");
      System.exit(1);
    } catch (ProfilException e) {
      System.err.println("ProfilException : " + e.getMessage());
      System.exit(1);
    }
   
    try {
      HashMap<String,Profil> profils = Serialiser.deserialiser(Constantes.PROFIL);
     
      for (Profil p : profils.values())
        System.out.println(p.getPseudo());
    } catch (IOException e) {
      System.err.println("Lecture impossible du fichier sérialisé");
      e.printStackTrace();
      System.exit(1);
    }
   
    Profil p = null;
    try {
      p = Client.getProfil("tarek.tarek13");
    } catch (RemoteException e) {
      System.err.println("Remote Exception");
      System.exit(1);
    }
   
    try {
      p.setNom("JAOUAOUAOUANI");
    } catch (NullPointerException e) {
      System.err.println("Profil inexistant");
      System.exit(1);
    }
   
View Full Code Here

TOP

Related Classes of profil.Profil

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.