1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108
|
import java.util.Scanner;
import java.util.LinkedList;
import java.util.ListIterator;
public class Agenda {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
LinkedList<Evenement> l = new LinkedList<Evenement>();
//Evenement event;
char choix;
while(true) {
System.out.println("*************** MENU ******************");
System.out.println("1) Creer un nouvel Evènement.");
System.out.println("2) Ouvrir une base.");
System.out.println("3) Fermer une base.");
System.out.println("4) Consulter une base.");
System.out.println("5) Enregistrer un Evènement.");
System.out.println("6) Effacer un Evènement.");
System.out.println("7) Quitter ce logiciel");
System.out.println("8) Visualiser les Evènements.");
System.out.print("Votre choix : ");
choix = sc.nextLine().charAt(0);
switch(choix) {
case '1':
l.add(creation(sc));
break;
case '6':
break;
case '7':
break;
case '8':
visualisation(l);
break;
default:
break;
}
if(choix == '7') break;
}
}
static void visualisation(LinkedList l) {
ListIterator li = l.listIterator();
while(li.hasNext()) {System.out.println(li.next().toString());}
}
static Evenement creation(Scanner sc) {
Evenement tmp = new Evenement(sc);
return tmp;
}
}
class Evenement {
Day d;
int heure,minute;
String lieu,description;
private static int nbInstances = 0;
public Evenement(Scanner sc) {
Day d = new Day(sc);
System.out.println("******************************************************************************");
System.out.println("************************ CREATION DE L'EVENEMENT ***************************");
System.out.println("******************************************************************************");
System.out.print("*********** heure ? ");
this.heure = sc.nextInt();
sc.nextLine();
System.out.print("**************** minute ? ");
this.minute = sc.nextInt();
sc.nextLine();
System.out.print("********************* lieu ? ");
this.lieu = sc.nextLine();
System.out.print("************************** description ? ");
this.lieu = sc.nextLine();
nbInstances++;
System.out.println(nbInstances + " évènement(s) crée(s)");
}
public String toString() {
String str = lieu+" le "+d.toString()+" à "+heure+"h"+minute+" : "+description;
return str;
}
public int getHeure() { return this.heure; }
public int getMinute() { return this.minute; }
public String getLieu() { return lieu; }
public String getDescription() { return description; }
}
class Day {
int jour,mois,annee;
public Day(Scanner sc) {
String date;
System.out.println("******************************************************************************");
System.out.println("**************************** CREATION DE LA DATE ***************************");
System.out.println("******************************************************************************");
System.out.print("*********** jour ? ");
this.jour = sc.nextInt();
sc.nextLine();
System.out.print("**************** mois ? ");
this.mois = sc.nextInt();
sc.nextLine();
System.out.print("********************* année ? ");
this.annee = sc.nextInt();
sc.nextLine();
}
public String toString() {
String str = jour+"/"+mois+"/"+annee;
return str;
}
} |