All pastes #255983 Raw Edit

Divers

public text v1 · immutable
#255983 ·published 2006-11-23 17:02 UTC
rendered paste body
// ------------------------------- ControleurAdministrateur.java ------------------------------
/** Package ctrl regroupe les controleurs du modele. **/
package ctrl;

import outils.XMLParserRepartiteur;
import modmission.Lire;
import java.io.*;

public class ControleurAdministrateur 
{
	private int rep;
	private int rep1;
	private int rep2;
	private boolean encore = true;
	private boolean encore2 = true;
	private boolean encore3 = true;
	private boolean encore4 = true;
	private String nom;
	private String prenom;
	
	private static ControleurAdministrateur unCtrlAdmin = new ControleurAdministrateur();
	
	private XMLParserRepartiteur unXMLRepart = new XMLParserRepartiteur();
	
	public ControleurAdministrateur(){}
	
	public static ControleurAdministrateur getInstance()
	{
		return unCtrlAdmin;
	}
	
	public void menuLogin() throws IOException
	{
		while(encore)
		{
			/* Menu Principal */
			System.out.println("===============================================");
			System.out.println("           MENU LOGIN ADMINISTRATEUR");
			System.out.println("===============================================");
			System.out.println(" ");
			System.out.println(" Veuillez entrez votre identifiant : ");
			System.out.println(" ");
			System.out.println(" 	   (ou taper Q pour quitter)");
			System.out.println(" ");
			System.out.print("Identifiant: ");
				
			/* lecture du choix */
			rep = Lire.lireInt();
					
			if(rep == 1)
			{
				encore=false;
				menuGerer();
			}
			else if(rep == 0)
			{ 
				/* Quitter */
			}
			else
			{ 
				System.out.println("Votre identifiant n'est pas connu par le systeme");
			}
		}
	}
	public void menuGerer() throws IOException
	{
		while(encore2)
		{
			/* Menu Principal */
			System.out.println("===============================================");
			System.out.println("           MENU GERER REPARTITEUR");
			System.out.println("===============================================");
			System.out.println(" ");
			System.out.println(" 	Vous voulez : ");
			System.out.println(" 		1- Ajouter un Repartiteur");
			System.out.println(" 		2- Supprimer un Repartiteur");
			System.out.println(" ");
			System.out.println(" 	   (ou taper Q pour quitter)");
			System.out.println(" ");
			System.out.print("Entrer votre choix: ");
				
			/* lecture du choix */
			rep1 = Lire.lireInt();
					
			/* traitement du choix */
			if(rep1 == 1)
			{
				ajouterRepartiteur();
			}
			else if(rep1 == 2)
			{
				supprimerRepartiteur();
			}
			else if(rep1 == 0)
			{
				/* Quitter */
			}
			else
			{
				System.out.println("Choix non valide");
			}
		}
	}
	public void ajouterRepartiteur() throws IOException
	{
		while(encore3)
		{
			/* Menu Principal */
			System.out.println("===============================================");
			System.out.println("        MENU GERER REPARTITEUR - AJOUTER");
			System.out.println("===============================================");
			System.out.println(" ");
			System.out.println(" 	Veuillez saisir : ");
			System.out.println(" 		Son Nom : ");
			nom = Lire.lireString();
			System.out.println(" 		Son Prenom : ");
			prenom = Lire.lireString();
 			encore3=false;
 			try
			{
 				unXMLRepart.ajouteRepartiteur(nom,prenom);
				System.exit(0);
			}
			catch(Exception e){e.printStackTrace();}
		}
	}
	public void supprimerRepartiteur() throws IOException
	{
		/* Menu Principal */
		System.out.println("===============================================");
		System.out.println("           MENU GERER REPARTITEUR");
		System.out.println("===============================================");
		System.out.println(" ");
		System.out.println(" 	Liste des répartiteurs : ");
		System.out.println(" ");
		try
		{
			unXMLRepart.parseRepartiteur("repartiteur.xml");
		}
		catch(Exception e){e.printStackTrace();}
		for (int i=0;i<unXMLRepart.getLesRepartiteurs().size();i++) 
		{
			System.out.println("           "+unXMLRepart.getLesRepartiteurs().elementAt(i).getIdPersonnel() + " - "+unXMLRepart.getLesRepartiteurs().elementAt(i).getNom()+" "+unXMLRepart.getLesRepartiteurs().elementAt(i).getPrenom());
		}
		System.out.println(" ");
		System.out.println(" 	Quel repartiteur voulez vous supprimer ? ");
		System.out.println(" ");
		System.out.println(" 	   (ou taper Q pour quitter)");
		System.out.println("Entrer votre choix: ");
		System.out.println(" ");
		/* lecture du choix */
		rep2 = Lire.lireInt();
					
// 		if/* Si le nombre est un identifiant alors on demande comfirmation de suppression*/)
// 		{
			System.out.println(" 	Etes vous sur de vouloir supprimer "+unXMLRepart.getLesRepartiteurs().elementAt(rep2).getNom()+" "+unXMLRepart.getLesRepartiteurs().elementAt(rep2).getPrenom()+" ?");
			System.out.println(" ");
			System.out.println(" 	Quel repartiteur voulez vous supprimer ? ");
			System.out.println(" ");
			System.out.println(" 	   (ou taper Q pour quitter)");
			
// 		}
// 		else if(rep == 0)
// 		{ 
// 			/* Quitter */
// 		}
// 		else
// 		{ 
// 			System.out.println("L'identifiant n'est pas connu par le systeme");
// 		}
	}
}//fin class ControleurAdministrateur