Grosse MàJ
This commit is contained in:
249
divers/IHM_Acteur.java
Normal file
249
divers/IHM_Acteur.java
Normal file
@ -0,0 +1,249 @@
|
||||
//
|
||||
//
|
||||
// Generated by StarUML(tm) Java Add-In
|
||||
//
|
||||
// @ Project : Untitled
|
||||
// @ File Name : IHM_Acteur.java
|
||||
// @ Date : 20/01/2008
|
||||
// @ Author :
|
||||
//
|
||||
//
|
||||
|
||||
|
||||
|
||||
package IHM;
|
||||
|
||||
import Documents.Element;
|
||||
import java.io.*;
|
||||
|
||||
|
||||
public class IHM_Acteur {
|
||||
public Gestion.Fabrique gestionnaire = Gestion.Fabrique.getInstance();
|
||||
|
||||
|
||||
public void AfficherDoc() {
|
||||
int ref = 0;
|
||||
System.out.println("Entrez le numero du document à afficher:");
|
||||
BufferedReader bfr = new BufferedReader(new InputStreamReader(System.in));
|
||||
try {ref = new Integer(bfr.readLine());}
|
||||
catch(IOException e) {e.printStackTrace();}
|
||||
try{System.out.println(gestionnaire.getElement(ref).afficher());}
|
||||
catch(IndexOutOfBoundsException e) {System.out.println("Element inexistant!");}
|
||||
}
|
||||
public Documents.Element getDocument() {
|
||||
int ref = 0;
|
||||
System.out.println("Entrez le numero du document dans lequel ajouter l'element:");
|
||||
BufferedReader bfr = new BufferedReader(new InputStreamReader(System.in));
|
||||
try {ref = new Integer(bfr.readLine());}
|
||||
catch(IOException e) {e.printStackTrace();}
|
||||
try{return gestionnaire.getElement(ref);}
|
||||
catch(IndexOutOfBoundsException e) {System.out.println("Element inexistant!");}
|
||||
return null;
|
||||
}
|
||||
public void listeDocuments() {
|
||||
for(int i = 1; i < gestionnaire.documents.size();i++)
|
||||
{
|
||||
Element e = gestionnaire.getElement(i);
|
||||
if(e instanceof Documents.Section)
|
||||
{
|
||||
if(e.getNiveau() == 0)
|
||||
System.out.println(e.afficher());
|
||||
}
|
||||
}
|
||||
try{new BufferedReader(new InputStreamReader(System.in)).readLine();}
|
||||
catch(IOException e) {}
|
||||
}
|
||||
public void noter() {
|
||||
int ref = 0;
|
||||
System.out.println("Entrez le numero du document à noter:");
|
||||
BufferedReader bfr = new BufferedReader(new InputStreamReader(System.in));
|
||||
try {ref = new Integer(bfr.readLine());}
|
||||
catch(IOException e) {e.printStackTrace();}
|
||||
try{
|
||||
Element el = gestionnaire.getElement(ref);
|
||||
System.out.println("Entrez la note:");
|
||||
try {int note = new Integer(bfr.readLine());
|
||||
el.setCoeff(note);
|
||||
}
|
||||
catch(IOException e) {System.out.println("La note entrée n'est pas correcte!");}
|
||||
}
|
||||
catch(IndexOutOfBoundsException e) {System.out.println("Element inexistant!");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void annoter() {
|
||||
int ref = 0;
|
||||
System.out.println("Entrez le numero du document à noter:");
|
||||
BufferedReader bfr = new BufferedReader(new InputStreamReader(System.in));
|
||||
try {ref = new Integer(bfr.readLine());}
|
||||
catch(IOException e) {e.printStackTrace();}
|
||||
try{
|
||||
Element el = gestionnaire.getElement(ref);
|
||||
System.out.println("Entrez l'annotation:");
|
||||
try {
|
||||
String annot = bfr.readLine();
|
||||
el.setAnnotation(annot);
|
||||
}
|
||||
catch(IOException e) {System.out.println("Entrée incorrecte!");}
|
||||
}
|
||||
catch(IndexOutOfBoundsException e) {System.out.println("Element inexistant!");
|
||||
}
|
||||
}
|
||||
public void creerDocument() {
|
||||
System.out.println("Entrez le titre du document :");
|
||||
BufferedReader bfr = new BufferedReader(new InputStreamReader(System.in));
|
||||
String titre="";
|
||||
try {
|
||||
/** Lecture d'une ligne : */
|
||||
titre = bfr.readLine();
|
||||
this.gestionnaire.CreateElem(titre);
|
||||
} catch( IOException e ) {System.out.println("Titre incorrect");}
|
||||
}
|
||||
|
||||
public void modifierDocument(int ref) {
|
||||
//Redacteur
|
||||
}
|
||||
public int identifier() {
|
||||
int rep = 1;
|
||||
System.out.println("Pour vous logguer en tant que redacteur, entrez votre code de 3 lettres: (FIN pour quitter) ");
|
||||
BufferedReader bfr = new BufferedReader(new InputStreamReader(System.in));
|
||||
String code="";
|
||||
try {
|
||||
/** Lecture d'une ligne : */
|
||||
code = bfr.readLine();
|
||||
} catch( IOException e ) {e.printStackTrace();}
|
||||
if(code.equals("RED"))
|
||||
{rep = 2;}
|
||||
else if (code.equals("FIN"))
|
||||
{rep = 3;}
|
||||
return rep;
|
||||
}
|
||||
public static void main(String[] args){
|
||||
IHM_Acteur ihm = new IHM_Acteur();
|
||||
int type = ihm.identifier();
|
||||
while(type != 3)
|
||||
{
|
||||
if(type == 1)
|
||||
{ ihmLecteur(ihm);}
|
||||
else
|
||||
{ihmRedacteur(ihm);}
|
||||
type= ihm.identifier();
|
||||
}
|
||||
}
|
||||
public static void ihmLecteur(IHM_Acteur ihm)
|
||||
{
|
||||
String ligne = "";
|
||||
BufferedReader bfr = new BufferedReader(new InputStreamReader(System.in));
|
||||
|
||||
while(!(ligne.equals("FIN")))
|
||||
{
|
||||
menuLec();
|
||||
try {
|
||||
System.out.println("Entrez votre choix: ");
|
||||
ligne = bfr.readLine();
|
||||
}catch( IOException e ) {e.printStackTrace();}
|
||||
|
||||
int choix = new Integer(ligne);
|
||||
switch(choix) {
|
||||
case 1: ihm.listeDocuments(); break;
|
||||
case 2: ihm.AfficherDoc(); break;
|
||||
case 3: ihm.annoter(); break;
|
||||
case 4: ihm.noter(); break;
|
||||
case 5: ligne = "FIN"; break;
|
||||
}
|
||||
}
|
||||
}
|
||||
public void creerElement(IHM_Acteur ihm)
|
||||
{
|
||||
String ligne ="";
|
||||
BufferedReader bfr = new BufferedReader(new InputStreamReader(System.in));
|
||||
menuElem();
|
||||
try {
|
||||
System.out.println("Entrez votre choix: ");
|
||||
ligne = bfr.readLine();
|
||||
}catch( IOException e ) {e.printStackTrace();}
|
||||
|
||||
int choix = new Integer(ligne);
|
||||
switch(choix) {
|
||||
case 1: ihm.listeDocuments(); break;
|
||||
case 2: ihm.creerSection(); break;
|
||||
case 3: ihm.creerTexte(); break;
|
||||
case 4: //ihm.creerImage(); break;
|
||||
case 5: ligne = "FIN"; break;
|
||||
}
|
||||
|
||||
}
|
||||
public static void ihmRedacteur(IHM_Acteur ihm)
|
||||
{
|
||||
String ligne = "";
|
||||
BufferedReader bfr = new BufferedReader(new InputStreamReader(System.in));
|
||||
|
||||
while(!ligne.equals("FIN"))
|
||||
{
|
||||
menuRed();
|
||||
try {
|
||||
System.out.println("Entrez votre choix: (FIN pour quitter)");
|
||||
ligne = bfr.readLine();
|
||||
int choix = new Integer(ligne);
|
||||
switch(choix) {
|
||||
case 1: ihm.listeDocuments(); break;
|
||||
case 2: ihm.AfficherDoc(); break;
|
||||
case 3: ihm.creerDocument(); break;
|
||||
case 4: ihm.creerElement(ihm); break;
|
||||
case 5: ihm.modifierDocument(choix); break;
|
||||
case 6: ligne = "FIN"; break;
|
||||
}
|
||||
}catch( IOException e ) {e.printStackTrace();}
|
||||
}
|
||||
}
|
||||
public void creerSection() {
|
||||
Documents.Section el = (Documents.Section) this.getDocument();
|
||||
System.out.println("Entrez le titre de la section à ajouter:");
|
||||
BufferedReader bfr = new BufferedReader(new InputStreamReader(System.in));
|
||||
try{String titre = bfr.readLine();
|
||||
Documents.Section sec= this.gestionnaire.CreateElem(titre);
|
||||
if(sec == null)
|
||||
{return;}
|
||||
el.addElement(sec);}
|
||||
catch(IOException e) {System.out.println("Pas bien!");}
|
||||
|
||||
}
|
||||
public void creerTexte() {
|
||||
Documents.Section el = (Documents.Section) this.getDocument();
|
||||
System.out.println("Entrez l'auteur du texte:");
|
||||
BufferedReader bfr = new BufferedReader(new InputStreamReader(System.in));
|
||||
try{String auteur = bfr.readLine();
|
||||
System.out.println("Saisissez le texte:");
|
||||
String texte = bfr.readLine();
|
||||
Documents.Texte txt= this.gestionnaire.CreateElem(texte, auteur);
|
||||
if(txt == null)
|
||||
{return;}
|
||||
el.addElement(txt);}
|
||||
catch(IOException e) {System.out.println("Pas bien!");}
|
||||
}
|
||||
public static void menuLec() {
|
||||
System.out.println("1: Lister les documents");
|
||||
System.out.println("2: Afficher un document");
|
||||
System.out.println("3: Annoter un document");
|
||||
System.out.println("4: Noter un document");
|
||||
System.out.println("5: Se déconnecter");
|
||||
}
|
||||
|
||||
public static void menuRed() {
|
||||
System.out.println("1: Lister les documents");
|
||||
System.out.println("2: Afficher un document");
|
||||
System.out.println("3: Créer un document");
|
||||
System.out.println("4: Créer un element et l'ajouter");
|
||||
System.out.println("5: Modifier un element");
|
||||
System.out.println("6: Se déconnecter");
|
||||
}
|
||||
public static void menuElem() {
|
||||
System.out.println("1: Lister les documents");
|
||||
System.out.println("2: Créer et ajouter une section");
|
||||
System.out.println("3: Créer et ajouter un texte");
|
||||
System.out.println("4: Créer et ajouter une image");
|
||||
System.out.println("5: Revenir au menu");
|
||||
|
||||
}
|
||||
}
|
31
divers/jeuChargementDonnees.java
Normal file
31
divers/jeuChargementDonnees.java
Normal file
@ -0,0 +1,31 @@
|
||||
public void jeuDeDonnees(){
|
||||
|
||||
/* Creation du document */
|
||||
Documents.Section el = this.gestionnaire.CreateElem("Chasse à la mouche");
|
||||
|
||||
/* Creation d'une section */
|
||||
Documents.Section el2 = this.gestionnaire.createElem("Chapitre 1");
|
||||
el.ajouterElement(el2);
|
||||
|
||||
/* Ajout de texte */
|
||||
el2.ajouterElement("Prenez un morceau de tissu vaudoux fraîchement récupéré d'un cadavre.");
|
||||
|
||||
/* Ajout d'image */
|
||||
el2.ajouterElement(150,150,"Image d'un cadavre vaudoux");
|
||||
|
||||
Documents.Section el3 = this.gestionnaire.createElem("Chapitre 2");
|
||||
el.ajouterElement(el3);
|
||||
el3.ajouterElement("Trouvez une mouche");
|
||||
|
||||
Documents.Section el4 = this.gestionnaire.createElem("Chapitre 3");
|
||||
el.ajouterElement(el4);
|
||||
el4.ajouterElement("Lancez le tissu vaudoux au dessus de la mouche et patientez que la mouche vienne se loger dans le tissu, après quoi le tissu prend pleine possession de ladite mouche.");
|
||||
|
||||
|
||||
/* Création d'un autre document */
|
||||
Documents.Section doc = this.gestionnaire.CreateElem("Javana Split");
|
||||
|
||||
Documents.Section doc2 = this.gestionnaire.createElem("Chapitre 1");
|
||||
doc.ajouterElement(doc2);
|
||||
doc2.ajouterElement("Faites une application Java, lancez, cela plante ! Beau Javana Split que nous avons là !");
|
||||
}
|
Reference in New Issue
Block a user