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 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203
|
public class Projet_Devis_2014 {
public static void main(String[] args) {
// Tableaux de données
String tabSections[] = new String[25];
String tabArticles[] = new String[100];
int[][] tabLignes = new int[100][3];
Terminal.sautDeLigne();
Terminal.ecrireString("\t"
+ "---------- Logiciel d'édition de devis / factures ----------");
Terminal.sautDeLigne();
boolean run = true;
while (run) {
// Déclenche les méthodes suivant le choix effectué dans le menu
// principal
int varChoixMenu = afficherMenu();
if (varChoixMenu == 1) {
creerSection(tabSections);
}
if (varChoixMenu == 2) {
afficherSections(tabSections);
}
if (varChoixMenu == 7) {
// Fin du programme
run = false;
}
}
}
public static int afficherMenu() {
// Affichage du menu principal
Terminal.sautDeLigne();
Terminal.ecrireStringln("\t" + "\t" + "\t"
+ "1: Creer nouvelle section");
Terminal.ecrireStringln("\t" + "\t" + "\t"
+ "2: Ouvrir une section existante");
Terminal.ecrireStringln("\t" + "\t" + "\t" + "3: Supprimer une section");
Terminal.ecrireStringln("\t" + "\t" + "\t" + "4: Creer une ligne");
Terminal.ecrireStringln("\t" + "\t" + "\t" + "5: Effacer une ligne");
Terminal.ecrireStringln("\t" + "\t" + "\t" + "6: Voir Devis / Facture");
Terminal.ecrireStringln("\t" + "\t" + "\t" + "7: Sortir");
Terminal.sautDeLigne();
// Enregistre et vérifie le choix utilisateur dans le menu principal
boolean testReponse = false;
int varChoixMenu = 0;
while (testReponse == false) {
Terminal.sautDeLigne();
Terminal.ecrireString(" ==> " + "\t"
+ "Veuillez entrer votre choix : ");
Terminal.sautDeLigne();
varChoixMenu = Terminal.lireInt();
if (varChoixMenu < 1 || varChoixMenu > 7) {
testReponse = false;
Terminal.ecrireString(" ==> "
+ "\t"
+ "Le choix rentré n'est pas valide, vous devez rentrer un nombre entre 1 et 7");
Terminal.sautDeLigne();
} else {
testReponse = true;
}
}
return varChoixMenu;
}
public static void creerSection(String[] tabSections) {
String varValeur = null;
Terminal.ecrireString(" ==> " + "\t"
+ "Veuillez rentrer le titre de la nouvelle section : ");
varValeur = Terminal.lireString();
remplirTab1Dim(tabSections, varValeur);
poursuivreCreation(tabSections);
}
public static void afficherSections(String[] tabSections) {
Terminal.sautDeLigne();
Terminal.ecrireStringln(" ==> " + "\t"
+ "Liste des sections existantes :");
afficherTab1Dim(tabSections);
afficherMenu();
}
public static void effacerSection(String[] tabSections) {
}
public static void creerLigne() {
}
public static void afficherDocument() {
}
public static void poursuivreCreation(String[] tabSections) {
// Demande à l'utilisateur s'il veut poursuivre
// la création d'une autre ligne ou section par un sous-menu
// et teste si le choix rentré est correct
int choixPoursuivre = 0;
Terminal.sautDeLigne();
Terminal.sautDeLigne();
Terminal.ecrireString(" ==> " + "\t" + "\t"
+ "Que desirez vous faire ?");
Terminal.sautDeLigne();
Terminal.sautDeLigne();
Terminal.ecrireStringln("\t" + "1. = Creer une nouvelle ligne");
Terminal.ecrireStringln("\t" + "2. = Creer une nouvelle section");
Terminal.ecrireStringln("\t" + "3. = Voir document");
Terminal.ecrireStringln("\t" + "4. = Menu Principal");
Terminal.sautDeLigne();
Terminal.ecrireString(" ==> " + "\t" + "\t"
+ "Veuillez entrer votre choix : ");
// Teste la réponse utilisateur
boolean testReponse = false;
while (testReponse == false) {
Terminal.sautDeLigne();
choixPoursuivre = Terminal.lireInt();
if (choixPoursuivre < 1 || choixPoursuivre > 4) {
testReponse = false;
Terminal.ecrireString(" ==> "
+ "\t"
+ "Le choix rentré n'est pas valide, vous devez rentrer un nombre entre 1 et 4");
Terminal.sautDeLigne();
Terminal.ecrireString(" ==> " + "\t" + "\t"
+ "Veuillez entrer votre choix : ");
} else {
testReponse = true;
}
// Actions à éxécuter suivant le choix effectué dans le menu
if (choixPoursuivre == 1) {
creerLigne();
}
if (choixPoursuivre == 2) {
creerSection(tabSections);
}
if (choixPoursuivre == 3) {
afficherDocument();
}
if (choixPoursuivre == 4) {
afficherMenu();
}
}
}
public static void remplirTab1Dim(String[] t, String varValeur) {
for (int i = 0; i < t.length; i++)
if (t[i] == null) {
t[i] = varValeur;
break;
}
}
public static void afficherTab1Dim(String[] t) {
// Vérifie que le tableau ne soit pas vide :
boolean estVide = true;
for (int i = 0; i < t.length; i++) {
if (t[i] != null) {
estVide = false;
break;
}
}
if (estVide) {
Terminal.sautDeLigne();
Terminal.ecrireString(" ==> "
+ "\t"
+ "-- AVERTISSEMENT : Aucune donnée n'a encore été enregistrée --");
Terminal.sautDeLigne();
} else {
// Affiche la liste des éléments du tableau
for (int j = 0; j < t.length; j++) {
if (t[j] != null) {
Terminal.ecrireStringln("\t" + "\t" + (j + 1) + ". " + t[j]);
}
}
}
}
} |