NotesWhat is notes.io?

Notes brand slogan

Notes - notes.io

package Client;

import java.util.Scanner;

import Requete_Reponse.ReponseAdd;
import Requete_Reponse.RequeteAdd;


public class ClientNickName {

public static final boolean VERBOSE = false;

private Client client;

public ClientNickName(Client client) {
this.client = client;
}

public void interfaceConsole() {
Scanner sc = new Scanner(System.in);
while (true) {
System.out.println("Interface du client de surnoms");
System.out.println("Saisissez votre choix dans la liste suivante :");
System.out.println("1 - Ajouter un surnom");
System.out.println("2 - Modifier un surnom");
System.out.println("3 - Supprimer un surnom");
System.out.println("4 - Supprimer un nom");
System.out.println("5 - Obtenir les surnoms d'une personne");
System.out.println("6 - Obtenir le nom associe à un surnom");
System.out.println("7 - Quitter");

int choix = 0;

choix = Integer.parseInt(sc.next());


switch (choix) {
case 1:
ajouterSurnom();
break;
case 2:
modifierSurnom();
break;
case 3:
supprimerSurnom();
break;
case 4:
supprimerNom();
break;
case 5:
obtenirSurnoms();
break;
case 6:
obtenirNom();
break;
case 7:
System.out.println("Deconnexion...");
sc.close();
System.exit(0);
default:
System.out.println("Entree non reconnue");
}
}
}

/**
* Methode utilisee pour ajouter un surnom
*/
private void ajouterSurnom() {
Scanner sc = new Scanner(System.in);

// Demander le nom
System.out.println("Nom de l'utilisateur : ");
String nom = sc.next();

// Demander le surnom
System.out.println("Surnom à ajouter : ");
String surnom = sc.next();

if (VERBOSE) {
System.out.println("Le surnom " + surnom + " va etre ajoute à " + nom);
}

// TODO Construire la requete
// RequeteAdd req = new RequeteAdd(nom, surnom);
RequeteAdd req = new RequeteAdd();
System.out.println("req "+req);

// Envoyer le message
Object res = client.sendMessage(req);
ReponseAdd rep = (ReponseAdd) res;
System.out.println(" ---- Reponse du serveur : ");
rep.executer();
// TODO Verifier le bon fonctionnement
//rep.executer();

sc.close();
}

/**
* Methode utilisee pour supprimer le surnom associe à un nom
*/
private void supprimerSurnom() {
Scanner sc = new Scanner(System.in);

// Demander le surnom
System.out.println("Surnom à supprimer : ");
String surnom = sc.next();

if (VERBOSE) {
System.out.println("Le surnom " + surnom + " va etre supprime");
}

// TODO Construire la requete
Object req = null;

// Envoyer le message
Object rep = client.sendMessage(req);

// TODO Verifier le bon fonctionnement
if ((Boolean)rep == false) {
System.out.println("L'operation a echoue parce que " + req.msg");
} else {
System.out.println("Le surnom a ete supprime");
}
sc.close();
}

/**
* Methode utilisee pour modifier le surnom associe à un nom
*/
private void modifierSurnom() {
Scanner sc = new Scanner(System.in);

// Demander l'ancien surnom
System.out.println("Ancien surnom : ");
String vieuxSurnom = sc.next();

// Demander le nouveau surnom
System.out.println("Nouveau surnom : ");
String nouveauSurnom = sc.next();

if (VERBOSE) {
System.out.println("Le surnom " + vieuxSurnom + " va etre modifie en " + nouveauSurnom);
}

// TODO Construire la requete
Object req = null;

// Envoyer le message
Object rep = client.sendMessage(req);

// TODO Verifier le bon fonctionnement
if ((Boolean)rep == false) {
System.out.println("L'operation a echoue parce que " + req.msg");
} else {
System.out.println("Le surnom a ete modifie");
}
sc.close();
}

/**
* Methode utilisee pour obtenir les surnoms associes à un nom
*/
private void obtenirSurnoms() {
Scanner sc = new Scanner(System.in);

// Demander le nom
System.out.println("Nom : ");
String nom = sc.next();

if (VERBOSE) {
System.out.println("Les surnoms de " + nom + " vont etre recuperes ");
}

// TODO Construire la requete
Object req = null;

// Envoyer le message
Object rep = client.sendMessage(req);

// TODO Verifier le bon fonctionnement et afficher le resultat
if ((Boolean)rep == false) {
System.out.println("L'operation a echoue parce que " + req.msg");
} else {
System.out.println("Le surnom a ete modifie");
}
sc.close();
}

/**
* Methode utilisee pour obtenir le nom associe à un surnom
*/
private void obtenirNom() {
Scanner sc = new Scanner(System.in);

// Demander le surnom à rechercher
System.out.println("Surnom : ");
String surnom = sc.next();

if (VERBOSE) {
System.out.println("Le nom associe à " + surnom + " va etre recherche");
}

// TODO Construire la requete
Object req = null;

// Envoyer le message
Object rep = client.sendMessage(req);

// TODO Verifier le bon fonctionnement et afficher le resultat
if ((Boolean)rep == false) {
System.out.println("L'operation a echoue parce que " + req.msg");
} else {
System.out.println("Le nom associe est ...");
}
sc.close();

}

/**
* Methode utilisee pour supprimer tous les enregistrements concernant un nom
*/
private void supprimerNom() {
Scanner sc = new Scanner(System.in);

// Demander le nom
System.out.println("Nom à supprimer : ");
String nom = sc.next();

if (VERBOSE) {
System.out.println("Le nom " + nom + " va etre supprime de tous les enregistrements");
}

// TODO Construire la requete
Object req = null;

// Envoyer le message
Object rep = client.sendMessage(req);

// TODO Verifier le bon fonctionnement
if ((Boolean)rep == false) {
System.out.println("L'operation a echoue parce que " + req.msg");
} else {
System.out.println("Le nom a ete supprime");
}
sc.close();

}

public static void main(String[] args) {
ClientNickName client = new ClientNickName(new ClientObject("Client NickName", "127.0.0.1", 12345));


System.out.println("Client de Reservation connecte");

// Lancer l'interface client
//
client.interfaceConsole();

}
}
     
 
what is notes.io
 

Notes.io is a web-based application for taking notes. You can take your notes and share with others people. If you like taking long notes, notes.io is designed for you. To date, over 8,000,000,000 notes created and continuing...

With notes.io;

  • * You can take a note from anywhere and any device with internet connection.
  • * You can share the notes in social platforms (YouTube, Facebook, Twitter, instagram etc.).
  • * You can quickly share your contents without website, blog and e-mail.
  • * You don't need to create any Account to share a note. As you wish you can use quick, easy and best shortened notes with sms, websites, e-mail, or messaging services (WhatsApp, iMessage, Telegram, Signal).
  • * Notes.io has fabulous infrastructure design for a short link and allows you to share the note as an easy and understandable link.

Fast: Notes.io is built for speed and performance. You can take a notes quickly and browse your archive.

Easy: Notes.io doesn’t require installation. Just write and share note!

Short: Notes.io’s url just 8 character. You’ll get shorten link of your note when you want to share. (Ex: notes.io/q )

Free: Notes.io works for 12 years and has been free since the day it was started.


You immediately create your first note and start sharing with the ones you wish. If you want to contact us, you can use the following communication channels;


Email: [email protected]

Twitter: http://twitter.com/notesio

Instagram: http://instagram.com/notes.io

Facebook: http://facebook.com/notesio



Regards;
Notes.io Team

     
 
Shortened Note Link
 
 
Looding Image
 
     
 
Long File
 
 

For written notes was greater than 18KB Unable to shorten.

To be smaller than 18KB, please organize your notes, or sign in.