This repository was archived by the owner on Oct 14, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathApplication.java
More file actions
939 lines (811 loc) · 41.3 KB
/
Application.java
File metadata and controls
939 lines (811 loc) · 41.3 KB
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
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
import java.io.File;
import java.util.ArrayList;
import java.util.Scanner;
public class Application {
//
// Constantes
//
public static final int NOMBRE_TABLE = 15;
public static final int NOMBRE_BOISSON_CARTE = 5;
public static final int NOMBRE_PLAT_CARTE = 11;
public static final int H_OUVERTURE = 10;
public static final int H_FERMETURE = 10;
//
// Variables
//
protected ArrayList<Journee> listeDesJournee = new ArrayList<>();
public int currentDay = 0;
public Carte carteDuRestorant = new Carte();
protected ArrayList<Personnel> listeDesEmployees = new ArrayList<Personnel>();
protected Boolean tableDuJourDejaDistribué = false;
protected Stock stockGlbaleStock = new Stock();
//
// Getters/Setters
//
public ArrayList<Journee> getListeDesJournee() {
return this.listeDesJournee;
}
public int getCurrentDay() {
return this.currentDay;
}
public Carte getCarteDuRestorant() {
return this.carteDuRestorant;
}
public ArrayList<Personnel> getListeDesEmployees() {
return this.listeDesEmployees;
}
public Boolean isTableDuJourDejaDistribuee() {
return this.tableDuJourDejaDistribué;
}
public void addAJournee(Journee newJournee) {
this.listeDesJournee.add(newJournee);
for (int i = 1; i <= NOMBRE_TABLE; i++) {
newJournee.listeDesTables.add(new Table(i, getRandomNumber(1, 5) * 2));
}
}
public void ajouterEmploye(Personnel personnel) {
this.listeDesEmployees.add(personnel);
}
//
// Méthodes
//
public void startApp() {
addAJournee(new Journee(H_OUVERTURE, H_FERMETURE));
creerDossierDuJour();
try (Scanner scanner = new Scanner(System.in)) {
mainMenu(scanner);
}
}
public void mainMenu(Scanner scanner) {
displayMainMenu();
int choixEcran = scanner.nextInt();
switch (choixEcran) {
case 0:
break;
case 1:
ecranCommande(scanner);
break;
case 2:
ecranCuisine(scanner);
break;
case 3:
ecranBar(scanner);
break;
case 4:
ecranMonitoring(scanner);
break;
case 5:
ecranGestionPersonnel(scanner);
System.out.println("0- Pour continuer");
scanner.nextInt();
mainMenu(scanner);
break;
case 6:
affichageStock(scanner);
break;
case 7:
addition(scanner);
break;
case 8:
nextDay(scanner);
break;
default:
mainMenu(scanner);
break;
}
}
public void ecranCommande(Scanner scanner) {
displayCommandeMenu();
if (scanner.hasNextInt()) {
int choixEcran = scanner.nextInt();
switch (choixEcran) {
case 1:
demandeNomEtNumeroTable(0, scanner);
break;
case 2:
demandeNomEtNumeroTable(1, scanner);
break;
default:
mainMenu(scanner);
break;
}
}
}
public void demandeNomEtNumeroTable(int type, Scanner scanner) {
int numeroTable = 0;
// NOMBRE DE CLIENTS
System.out.println("\n\n\n\n\n\n\n\n\n\n\n\n\n\n");
System.out.println("1-Nouveau client : ");
System.out.println("2-Client ayant deja une table: ");
while (!scanner.hasNextInt()) {
System.err.println("Erreur : Veuillez entrer un nombre valide.");
scanner.next(); // Consommer la saisie incorrecte
}
int choixNewOrOld = scanner.nextInt();
// Choix Si NOUVEAU CLIENTS
if (choixNewOrOld == 1) {
System.out.println("\n\n\n\n\n\n\n\n\n\n\n\n\n\n");
System.out.println("Entrez le nombre de clients : ");
while (!scanner.hasNextInt()) {
System.err.println("Erreur : Veuillez entrer un nombre valide.");
scanner.next(); // Consommer la saisie incorrecte
}
int nbClients = scanner.nextInt();
if (nbClients > 10) {
System.err.println("Il n'y a pas de table pour autant de clients");
mainMenu(scanner);
}
// Consommer la fin de la ligne pour éviter les problèmes de décalage
scanner.nextLine();
// ASSIGNATION D'UNE TABLE
Journee journee = getListeDesJournee().get(getCurrentDay());
numeroTable = journee.conduireATable(nbClients);
if (numeroTable != 0) {
getListeDesJournee().get(getCurrentDay()).getListeDesTables().get(numeroTable).setTableOccupee(true); // On dit que cette table est desormais occupée
getListeDesJournee().get(getCurrentDay()).getListeDesTables().get(numeroTable).incrNombreDeCommandesTable(); // On augmente le nombre de commande sur cette table
}
else {
System.out.println("Il n'y a pas de table disponible.");
}
if (type == 0) { // Si c'est des plats
priseCommandePlat(numeroTable, scanner);
}
else if (type == 1) { // Si c'est des boissons
priseCommandeBoisson(numeroTable, scanner);
}
}
// Choix Si LES CLIENTS ONT DEJA UNE TABLE
else {
System.out.println("\n\n\n\n\n\n\n\n\n\n\n\n\n\n");
System.out.println("Entrez le numéro de table : ");
while (!scanner.hasNextInt()) {
System.err.println("Erreur : Veuillez entrer un numéro de table valide.");
scanner.next(); // Consommer la saisie incorrecte
}
numeroTable = scanner.nextInt();
// Consommer la fin de la ligne pour éviter les problèmes de décalage
scanner.nextLine();
// On retrouve le numero de la commande précédante
int numeroDeCommande = 100 * numeroTable + getListeDesJournee().get(getCurrentDay()).getListeDesTables().get(numeroTable).getNombreDeCommandesTable();
if (type == 0) { // Si c'est des plats
ajouterACommandePlat(numeroDeCommande, scanner);
}
else if (type == 1) { // Si c'est des boissons
ajouterACommandeBoisson(numeroDeCommande, scanner);
}
}
}
public void priseCommandePlat(int numTable, Scanner scanner) {
carteDuRestorant.printCartePlat();
// EXPLICATION NUMERO DE COMMANDE
/*
* Le numero de commande se divise en deux parties, le début correspond au numéro de la table et la fin correspond à la nième commande sur cette table
* Par exemple, si le numéro de commande est 1018, il faut lire séparement 10 et 18 ce qui indique qu'il s'agit de la 18ème commande sur la table 10
* Pour accéder au numéro de la table à partir du numéro de commande on divise par 100
* Pour savoir combien de commande on a fait sur la table on fait un modulo 100
*/
int numeroDeCommande = numTable * 100 + getListeDesJournee().get(getCurrentDay()).getListeDesTables().get(numTable).getNombreDeCommandesTable();
Commande newCommande = new Commande(numeroDeCommande);
ArrayList<Integer> listePlatCommande = new ArrayList<>();
boolean commandeEnd = false;
while (!commandeEnd) {
System.out.println("Saisissez le n° du plat choisi.(0 : pour valider la commande, -1 : annuler)");
int choixEcran = scanner.nextInt();
if (choixEcran == -1) {
commandeEnd = true;
return;
}
if (choixEcran != 0 && choixEcran <= NOMBRE_PLAT_CARTE) {
listePlatCommande.add(choixEcran);
System.out.println(carteDuRestorant.cartePlat[choixEcran - 1].nom);
} else if (choixEcran > NOMBRE_PLAT_CARTE) {
System.err.println("Erreur Chiffre mauvais");
System.out.println("0- Pour continuer");
scanner.nextInt();
mainMenu(scanner);
} else {
System.out.println("\n\n\n\n\n\n\n\n\n\n\n\n\n\n");
System.out.println("La commande a été validée, elle contient :");
for (int platCode : listePlatCommande) {
System.out.println(carteDuRestorant.cartePlat[platCode - 1].nom);
newCommande.ajoutPlatALaCommande(carteDuRestorant.cartePlat[platCode - 1]);
commandeEnd = true;
}
System.out.println("Le numéro de commande est le n°" + numeroDeCommande);
commandeEnd = true;
}
}
// Récupérer la journée actuelle
Journee journeeActuelle = listeDesJournee.get(currentDay);
// Récupérer la liste des tables de la journée actuelle
ArrayList<Table> listeDesTables = journeeActuelle.listeDesTables;
// Récupérer la table spécifique à mettre à jour
Table tableAModifier = listeDesTables.get(numTable);
// Ajouter une nouvelle commande à la table
tableAModifier.tableauDeCommandes.add(newCommande);
// Mettre à jour la table dans la liste des tables
listeDesTables.set(numTable, tableAModifier);
// Mettre à jour la journée dans la liste générale
listeDesJournee.set(currentDay, journeeActuelle);
System.out.println("0- Pour continuer");
scanner.nextInt();
mainMenu(scanner);
}
public void ajouterACommandePlat(int numeroDeCommande, Scanner scanner) {
carteDuRestorant.printCartePlat();
// On récupère l'ancienne commande
Commande newCommande = getListeDesJournee().get(getCurrentDay()).getListeDesTables().get(numeroDeCommande / 100).getCommande(numeroDeCommande % 100);
ArrayList<Integer> listePlatCommande = new ArrayList<>();
boolean commandeEnd = false;
while (!commandeEnd) {
System.out.println("Saisissez le n° du plat choisi.(0 : pour valider la commande, -1 : annuler)");
int choixEcran = scanner.nextInt();
if (choixEcran == -1) {
commandeEnd = true;
return;
}
if (choixEcran != 0 && choixEcran <= NOMBRE_PLAT_CARTE) {
listePlatCommande.add(choixEcran);
System.out.println(carteDuRestorant.cartePlat[choixEcran - 1].nom);
} else if (choixEcran > NOMBRE_PLAT_CARTE) {
System.err.println("Erreur Chiffre mauvais");
System.out.println("0- Pour continuer");
scanner.nextInt();
mainMenu(scanner);
} else {
System.out.println("\n\n\n\n\n\n\n\n\n\n\n\n\n\n");
System.out.println("La commande a été validée, elle contient :");
for (int platCode : listePlatCommande) {
System.out.println(carteDuRestorant.cartePlat[platCode - 1].nom);
newCommande.ajoutPlatALaCommande(carteDuRestorant.cartePlat[platCode - 1]);
commandeEnd = true;
}
System.out.println("Le numéro de commande est le n°" + numeroDeCommande);
commandeEnd = true;
}
}
// Récupérer la journée actuelle
Journee journeeActuelle = listeDesJournee.get(currentDay);
// Récupérer la liste des tables de la journée actuelle
ArrayList<Table> listeDesTables = journeeActuelle.listeDesTables;
// Récupérer la table spécifique à mettre à jour
Table tableAModifier = listeDesTables.get(numeroDeCommande / 100);
// Supprime la derniere commande de la table
tableAModifier.tableauDeCommandes.remove(numeroDeCommande % 100);
// Ajouter une nouvelle commande à la table
tableAModifier.tableauDeCommandes.add(newCommande);
// Mettre à jour la table dans la liste des tables
listeDesTables.set(numeroDeCommande % 100, tableAModifier);
// Mettre à jour la journée dans la liste générale
listeDesJournee.set(currentDay, journeeActuelle);
System.out.println("0- Pour continuer");
scanner.nextInt();
mainMenu(scanner);
}
public void priseCommandeBoisson(int numTable, Scanner scanner) {
carteDuRestorant.printCarteBoisson();
// EXPLICATION NUMERO DE COMMANDE
/*
* Le numero de commande se divise en deux parties, le début correspond au numéro de la table et la fin correspond à la nième commande sur cette table
* Par exemple, si le numéro de commande est 1018, il faut lire séparement 10 et 18 ce qui indique qu'il s'agit de la 18ème commande sur la table 10
* Pour accéder au numéro de la table à partir du numéro de commande on divise par 100
* Pour savoir combien de commande on a fait sur la table on fait un modulo 100
*/
int numeroDeCommande = numTable * 100 + getListeDesJournee().get(getCurrentDay()).getListeDesTables().get(numTable).getNombreDeCommandesTable();
Commande newCommande = new Commande(numeroDeCommande);
ArrayList<Integer> listeBoissonCommande = new ArrayList<>();
boolean commandeEnd = false;
while (!commandeEnd) {
System.out.println("Saisissez le n° de la boisson choisi.(0 : pour valider la commande, -1 : annuler)");
int choixEcran = scanner.nextInt();
if (choixEcran == -1) {
commandeEnd = true;
return;
}
if (choixEcran != 0 && choixEcran <= NOMBRE_BOISSON_CARTE) {
listeBoissonCommande.add(choixEcran);
System.out.println(carteDuRestorant.carteBoisson[choixEcran - 1].nom);
} else if (choixEcran > NOMBRE_BOISSON_CARTE) {
System.err.println("Erreur Chiffre mauvais");
System.out.println("0- Pour continuer");
scanner.nextInt();
mainMenu(scanner);
} else {
System.out.println("\n\n\n\n\n\n\n\n\n\n\n\n\n\n");
System.out.println("La commande a été validée, elle contient :");
for (int boissonCode : listeBoissonCommande) {
System.out.println(carteDuRestorant.carteBoisson[boissonCode - 1].nom);
newCommande.ajoutBoissonALaCommande(carteDuRestorant.carteBoisson[boissonCode - 1]);
commandeEnd = true;
}
System.out.println("Le numéro de commande est le n°" + numeroDeCommande);
commandeEnd = true;
}
}
// Récupérer la journée actuelle
Journee journeeActuelle = listeDesJournee.get(currentDay);
// Récupérer la liste des tables de la journée actuelle
ArrayList<Table> listeDesTables = journeeActuelle.listeDesTables;
// Récupérer la table spécifique à mettre à jour
Table tableAModifier = listeDesTables.get(numTable);
// Ajouter une nouvelle commande à la table
tableAModifier.tableauDeCommandes.add(newCommande);
// Mettre à jour la table dans la liste des tables
listeDesTables.set(numTable, tableAModifier);
// Mettre à jour la journée dans la liste générale
listeDesJournee.set(currentDay, journeeActuelle);
mainMenu(scanner);
}
public void ajouterACommandeBoisson(int numeroDeCommande, Scanner scanner) {
carteDuRestorant.printCarteBoisson();
// On récupère l'ancienne commande
Commande newCommande = getListeDesJournee().get(getCurrentDay()).getListeDesTables().get(numeroDeCommande / 100).getCommande(numeroDeCommande % 100);
ArrayList<Integer> listeBoissonCommande = new ArrayList<>();
boolean commandeEnd = false;
while (!commandeEnd) {
System.out.println("Saisissez le n° de la boisson choisi.(0 : pour valider la commande, -1 : annuler)");
int choixEcran = scanner.nextInt();
if (choixEcran == -1) {
commandeEnd = true;
return;
}
if (choixEcran != 0 && choixEcran <= NOMBRE_BOISSON_CARTE) {
listeBoissonCommande.add(choixEcran);
System.out.println(carteDuRestorant.carteBoisson[choixEcran - 1].nom);
} else if (choixEcran > NOMBRE_BOISSON_CARTE) {
System.err.println("Erreur Chiffre mauvais");
System.out.println("0- Pour continuer");
scanner.nextInt();
mainMenu(scanner);
} else {
System.out.println("\n\n\n\n\n\n\n\n\n\n\n\n\n\n");
System.out.println("La commande a été validée, elle contient :");
for (int boissonCode : listeBoissonCommande) {
System.out.println(carteDuRestorant.cartePlat[boissonCode - 1].nom);
newCommande.ajoutBoissonALaCommande(carteDuRestorant.carteBoisson[boissonCode - 1]);
commandeEnd = true;
}
System.out.println("Le numéro de commande est le n°" + numeroDeCommande);
commandeEnd = true;
}
}
// Récupérer la journée actuelle
Journee journeeActuelle = listeDesJournee.get(currentDay);
// Récupérer la liste des tables de la journée actuelle
ArrayList<Table> listeDesTables = journeeActuelle.listeDesTables;
// Récupérer la table spécifique à mettre à jour
Table tableAModifier = listeDesTables.get(numeroDeCommande / 100);
// Supprime la derniere commande de la table
tableAModifier.tableauDeCommandes.remove(numeroDeCommande % 100);
// Ajouter une nouvelle commande à la table
tableAModifier.tableauDeCommandes.add(newCommande);
// Mettre à jour la table dans la liste des tables
listeDesTables.set(numeroDeCommande % 100, tableAModifier);
// Mettre à jour la journée dans la liste générale
listeDesJournee.set(currentDay, journeeActuelle);
System.out.println("0- Pour continuer");
scanner.nextInt();
mainMenu(scanner);
}
public void ecranCuisine(Scanner scanner) {
//displayCuisineMenu();
//int choixEcran = scanner.nextInt();
// switch (choixEcran) {
// case 1:
System.out.println("");
ArrayList<Table> allTables = this.listeDesJournee.get(currentDay).listeDesTables;
int indexPrint = 0;
for (int i = 0; i < allTables.size(); i++) {
for (int y = 0; y < allTables.get(i).tableauDeCommandes.size(); y++) {
indexPrint++;
if (!allTables.get(i).tableauDeCommandes.get(y).isPret()) {
System.out.println(indexPrint + "- "
+ allTables.get(i).tableauDeCommandes.get(y).listeDesPlatsCommandes);
}
}
}
System.out.println("\n1 à 99- Pour Valider \n0- Pour retourner au menu");
int choixCommandePrete = scanner.nextInt();
if (choixCommandePrete == 0) {
mainMenu(scanner);
} else {
int indexChoisi = 0;
for (int i = 0; i < NOMBRE_TABLE; i++) {
for (int y = 0; y < allTables.get(i).tableauDeCommandes.size(); y++) {
indexChoisi++;
if (choixCommandePrete == indexChoisi) {
allTables.get(i).tableauDeCommandes.get(y).setPret(true);
Commande commandeModifie = allTables.get(i).tableauDeCommandes.get(y);
Journee journeeActuelle = listeDesJournee.get(currentDay);
// Récupérer la liste des tables de la journée actuelle
ArrayList<Table> listeDesTables = journeeActuelle.listeDesTables;
// Récupérer la table spécifique à mettre à jour
Table tableAModifier = listeDesTables.get(i);
// Ajouter une nouvelle commande à la table
tableAModifier.tableauDeCommandes.add(commandeModifie);
// Mettre à jour la table dans la liste des tables
listeDesTables.set(i, tableAModifier);
// Mettre à jour la journée dans la liste générale
listeDesJournee.set(currentDay, journeeActuelle);
ArrayList<Ingredients> retListOfIngredients = commandeModifie
.getAllIngredientsFromPlat();
stockGlbaleStock.removeStock(retListOfIngredients);
//System.out.println("Ingrédients Supprimer du stock");
}
// System.out.println(indexPrint+"-
// "+allTables.get(i).tableauDeCommandes.get(y).listeDesPlatsCommandes);
System.out.println("Commande N°" + indexChoisi + " à été validé");
}
}
}
System.out.println("\n0- Pour continuer");
scanner.nextInt();
mainMenu(scanner);
//break;
// default:
// mainMenu(scanner);
// break;
//}
}
public void ecranBar(Scanner scanner) {
//displayBarMenu();
// int choixEcran = scanner.nextInt();
// switch (choixEcran) {
// case 1:
System.out.println("");
ArrayList<Table> allTables = this.listeDesJournee.get(currentDay).listeDesTables;
int indexPrint = 0;
for (int i = 0; i < allTables.size(); i++) {
for (int y = 0; y < allTables.get(i).tableauDeCommandes.size(); y++) {
indexPrint++;
if (!allTables.get(i).tableauDeCommandes.get(y).isPret()) {
System.out.println(indexPrint + "- "
+ allTables.get(i).tableauDeCommandes.get(y).listeDesBoissonsCommandees);
}
}
}
System.out.println("\n1 à 99- Pour Valider \n0- Pour retourner au menu");
int choixCommandePrete = scanner.nextInt();
if (choixCommandePrete == 0) {
mainMenu(scanner);
} else {
int indexChoisi = 0;
for (int i = 0; i < allTables.size(); i++) {
for (int y = 0; y < allTables.get(i).tableauDeCommandes.size(); y++) {
indexChoisi++;
if (choixCommandePrete == indexChoisi) {
allTables.get(i).tableauDeCommandes.get(y).setPret(true);
Commande commandeModifie = allTables.get(i).tableauDeCommandes.get(y);
Journee journeeActuelle = listeDesJournee.get(currentDay);
// Récupérer la liste des tables de la journée actuelle
ArrayList<Table> listeDesTables = journeeActuelle.listeDesTables;
// Récupérer la table spécifique à mettre à jour
Table tableAModifier = listeDesTables.get(i);
// Ajouter une nouvelle commande à la table
tableAModifier.tableauDeCommandes.add(commandeModifie);
// Mettre à jour la table dans la liste des tables
listeDesTables.set(i, tableAModifier);
// Mettre à jour la journée dans la liste générale
listeDesJournee.set(currentDay, journeeActuelle);
}
// System.out.println(indexPrint+"-
// "+allTables.get(i).tableauDeCommandes.get(y).listeDesPlatsCommandes);
System.out.println("Commande N°" + indexChoisi + " à été validé");
}
}
}
System.out.println("0- Pour continuer");
scanner.nextInt();
mainMenu(scanner);
// break;
// default:
mainMenu(scanner);
//break;
//}
}
public void ecranMonitoring(Scanner scanner) {
// Ajoutez le code pour l'écran de monitoring
//Facture hello = new Facture();
displayChoixFacture();
if (scanner.hasNextInt()) {
int choixEcran = scanner.nextInt();
switch (choixEcran) {
case 1:
listeDesJournee.get(currentDay).factureJournee.affichageMenuStatsTickets();
break;
case 2:
listeDesJournee.get(currentDay).factureJournee.editionFichier(currentDay);
break;
default:
mainMenu(scanner);
break;
}
}
System.out.println("0- Pour continuer");
scanner.nextInt();
mainMenu(scanner);
// Ajouter demande si enregistrement dans un fichier
}
public void ecranGestionPersonnel(Scanner scanner) {
displayGestionPersonnelMenu();
int choixEcran = scanner.nextInt();
switch (choixEcran) {
case 1: // Affichage de la liste des employés
// On commence par afficher la liste des serveurs
System.out.println("\nServeurs :");
for (Personnel iPersonnel : getListeDesEmployees()) {
if (iPersonnel instanceof Serveur) { // On verifie si le personnel est un serveur
System.out.println(" " + iPersonnel.getPrenom() + " " + iPersonnel.getNom());
}
}
System.out.println("\nCuisiniers :");
for (Personnel iPersonnel : getListeDesEmployees()) {
if (iPersonnel instanceof Cuisinier) { // On verifie si le personnel est un serveur
System.out.println(" " + iPersonnel.getPrenom() + " " + iPersonnel.getNom());
}
}
System.out.println("\nBarmans :");
for (Personnel iPersonnel : getListeDesEmployees()) {
if (iPersonnel instanceof Barman) { // On verifie si le personnel est un serveur
System.out.println(" " + iPersonnel.getPrenom() + " " + iPersonnel.getNom());
}
}
System.out.println(); // fais un retour a la ligne
break;
case 2: // Distribution des tables
if (getListeDesEmployees().isEmpty()) {
System.err.println("Il n'y a pas de serveurs embauchés.");
System.out.println("0- Pour continuer");
scanner.nextInt();
mainMenu(scanner);
break;
}
// On récupère en premier la liste des serveurs
ArrayList<Serveur> listeDesServeurs = new ArrayList<>();
for (Personnel iPersonnel : getListeDesEmployees()) { // Pour tout le personnel
if (iPersonnel instanceof Serveur) { // On verifie si le personnel est un serveur
listeDesServeurs.add((Serveur) iPersonnel); // on cast le personnel en serveur et on
// l'ajoute dans la liste des serveurs
}
}
// Distribution des tables (une fois par jour)
if (isTableDuJourDejaDistribuee() == false) {
int nbServeurs = listeDesServeurs.size();
int nbTablesParServeur = NOMBRE_TABLE / nbServeurs;
int resteDivisionEuclidienne = NOMBRE_TABLE % nbServeurs; // On va compter les tables "en trop"
// comme un decompteur
int nbTableDejaDistribuee = 0; // On va compter le nombre de table que l'on distribue comme un
// compteur
for (Serveur iServeur : listeDesServeurs) { // Pour tout les serveur
ArrayList<Table> tableDuServeur = new ArrayList<>(); // On cree sa liste de table
int dernierNumeroTableADistribuerACeServeur = nbTablesParServeur + nbTableDejaDistribuee; // On
// regarde
// quel
// sera
// la
// derniere
// table
// à
// donner
// à
// ce
// serveur
for (int iTable = nbTableDejaDistribuee; iTable < dernierNumeroTableADistribuerACeServeur; iTable++) {
Journee journee = getListeDesJournee().get(getCurrentDay()); // On récupère la journée
tableDuServeur.add(journee.getListeDesTables().get(iTable)); // On ajoute cette table a la
// liste
nbTableDejaDistribuee++;
}
if (resteDivisionEuclidienne > 0) {
Journee journee = getListeDesJournee().get(getCurrentDay()); // On récupère la journée
tableDuServeur.add(journee.getListeDesTables().get(nbTableDejaDistribuee)); // On ajoute
// cette table a
// la liste
nbTableDejaDistribuee++;
resteDivisionEuclidienne--;
}
iServeur.addTables(tableDuServeur);
this.tableDuJourDejaDistribué = true;
}
}
// Affichage des tables
System.out.println("\nDistribution du jour :");
for (Serveur iServeur : listeDesServeurs) {
iServeur.printTableGeres();
}
System.out.println("\n0- Pour continuer");
scanner.nextInt();
mainMenu(scanner);
break;
case 3: // Ajouter serveur
ajouterServeur(scanner);
break;
case 4: // Ajouter cuisinier
ajouterCuisinier(scanner);
break;
case 5: // Ajouter barman
ajouterBarman(scanner);
break;
default:
mainMenu(scanner);
break;
}
}
private void ajouterServeur(Scanner scanner) {
System.out.println("Entrez le nom du nouveau serveur");
while (!scanner.hasNext()) {
System.err.println("Erreur : Veuillez entrer le nom du nouveau serveur");
scanner.next(); // Consommer la saisie incorrecte
}
String nom = scanner.next();
// Consommer la fin de la ligne pour éviter les problèmes de décalage
scanner.nextLine();
System.out.println("Entrez le prénom du nouveau serveur");
while (!scanner.hasNext()) {
System.err.println("Erreur : Veuillez entrer le prénom du nouveau serveur");
scanner.next(); // Consommer la saisie incorrecte
}
String prenom = scanner.next();
// Consommer la fin de la ligne pour éviter les problèmes de décalage
scanner.nextLine();
Serveur newServeur = new Serveur(nom, prenom);
ajouterEmploye(newServeur);
}
private void ajouterCuisinier(Scanner scanner) {
System.out.println("Entrez le nom du nouveau cuisinier");
while (!scanner.hasNext()) {
System.err.println("Erreur : Veuillez entrer le nom du nouveau cuisinier");
scanner.next(); // Consommer la saisie incorrecte
}
String nom = scanner.next();
// Consommer la fin de la ligne pour éviter les problèmes de décalage
scanner.nextLine();
System.out.println("Entrez le prénom du nouveau cuisinier");
while (!scanner.hasNext()) {
System.err.println("Erreur : Veuillez entrer le prénom du nouveau cuisinier");
scanner.next(); // Consommer la saisie incorrecte
}
String prenom = scanner.next();
// Consommer la fin de la ligne pour éviter les problèmes de décalage
scanner.nextLine();
Cuisinier newCuisinier = new Cuisinier(nom, prenom);
ajouterEmploye(newCuisinier);
}
private void ajouterBarman(Scanner scanner) {
System.out.println("Entrez le nom du nouveau barman");
while (!scanner.hasNext()) {
System.err.println("Erreur : Veuillez entrer le nom du nouveau barman");
scanner.next(); // Consommer la saisie incorrecte
}
String nom = scanner.next();
// Consommer la fin de la ligne pour éviter les problèmes de décalage
scanner.nextLine();
System.out.println("Entrez le prénom du nouveau barman");
while (!scanner.hasNext()) {
System.err.println("Erreur : Veuillez entrer le prénom du nouveau barman");
scanner.next(); // Consommer la saisie incorrecte
}
String prenom = scanner.next();
// Consommer la fin de la ligne pour éviter les problèmes de décalage
scanner.nextLine();
Barman newBarman = new Barman(nom, prenom);
ajouterEmploye(newBarman);
}
public void affichageStock(Scanner scanner) {
for (int i = 0; i < this.stockGlbaleStock.listDesIngredientsDispo.size(); i++) {
System.out.print(this.stockGlbaleStock.listDesIngredientsDispo.get(i).nom + " ; ");
}
System.out.println("\n0- Pour continuer");
scanner.nextInt();
mainMenu(scanner);
}
private void nextDay(Scanner scanner) {
this.currentDay++;
this.tableDuJourDejaDistribué = false;
addAJournee(new Journee(H_FERMETURE, H_OUVERTURE));
creerDossierDuJour();
System.out.println("Journée suivante!");
System.out.println("\n0- Pour continuer");
scanner.nextInt();
mainMenu(scanner);
}
public void addition(Scanner scanner) {
// Faire scanner pour numTable, numCommande
// Elles sont ici initialisées manuellement
// int numTable = 1;
// int numCommande = 1;
System.out.println("Entrez le numéro de table");
int numTable = scanner.nextInt();
if (getListeDesJournee().get(getCurrentDay()).getListeDesTables().get(numTable).isTableOccupee() == false) {
System.err.println("Il n'y a pas de commande sur cette table actuellement.");
System.out.println("\n0- Pour continuer");
scanner.nextInt();
mainMenu(scanner);
}
// On récupère la liste des journées, on regarde le jour actuel, on récupère la liste des tables du jour et on selectionne celle qui nous interesse
// enfin on prend la derniere commande sur cette table.
int numCommande = getListeDesJournee().get(getCurrentDay()).getListeDesTables().get(numTable).getNombreDeCommandesTable();;
System.out.println("ici ok");
Commande commandeDemandee = listeDesJournee.get(currentDay).listeDesTables.get(numTable).tableauDeCommandes.get(numCommande-1);
System.out.println("ici ok2");
Addition additionAEditer = new Addition();
System.out.println("ici ok3");
additionAEditer.newAddition(commandeDemandee);
System.out.println("ici ok4");
//additionAEditer.enregistrementFichier(currentDay);
additionAEditer.editionTicket(currentDay);
System.out.println("ici ok5");
listeDesJournee.get(currentDay).factureJournee.setNouveauTicket(additionAEditer.numTable, additionAEditer.numCommande, additionAEditer.somme);
// On dit que cette table n'est plus occupée
getListeDesJournee().get(getCurrentDay()).getListeDesTables().get(numTable).setTableOccupee(false);
System.out.println("\n0- Pour continuer");
scanner.nextInt();
mainMenu(scanner);
}
public int getRandomNumber(int min, int max) {
return (int) ((Math.random() * (max - min + 1)) + min);
}
public void creerDossierDuJour() {
File file = new File("Jour" + getCurrentDay() + "\\");
if (file.exists()) {
System.out.println("Le dossier existe déjà : " + file.getAbsolutePath());
} else {
if (file.mkdir()) {
System.out.println("Ajout du dossier jour : " + file.getAbsolutePath() + " avec succès");
} else {
System.out.println("Echec sur le dossier : " + file.getAbsolutePath());
}
}
}
// Méthodes pour afficher les différents menus
private void displayMainMenu() {
System.out.println("\n\n\n\n\n\n\n\n\n\n\n\n\n\n");
System.out.println("------------------------------------------------------");
System.out.println("-----------------Max Burger Application---------------");
System.out.println("-----------------'Votre Burger Préféré'---------------");
System.out.println("--------------------Copyright 2023--------------------");
System.out.println("------------------------------------------------------");
System.out.println("\n\n");
System.out.println("Quel écran souhaitez-vous afficher?");
System.out.println("1- Ecran prise de commande");
System.out.println("2- Ecran cuisine");
System.out.println("3- Ecran bar");
System.out.println("4- Ecran monitoring");
System.out.println("5- Ecran gestion personnel");
System.out.println("6- Afficher stock");
System.out.println("7- Demande d'addition");
System.out.println("8- Prochaine journée");
System.out.println("0- Exit");
}
private void displayCommandeMenu() {
System.out.println("\n\n\n\n\n\n\n\n\n\n\n\n\n\n");
System.out.println("0- Retour");
System.out.println("1- Menu des Plats");
System.out.println("2- Menu des Boissons");
}
private void displayChoixFacture() {
System.out.println("\n\n\n\n\n\n\n\n\n\n\n\n\n\n");
System.out.println("0- Retour");
System.out.println("1- Afficher récap journée");
System.out.println("2- Enregistrer récap journée");
}
// private void displayCuisineMenu() {
// System.out.println("\n\n\n\n\n\n\n\n\n\n\n\n\n\n");
// System.out.println("0- Retour");
// System.out.println("1- Afficher les commandes à faire en cuisine");
// }
// private void displayBarMenu() {
// System.out.println("\n\n\n\n\n\n\n\n\n\n\n\n\n\n");
// System.out.println("0- Retour");
// System.out.println("1- Afficher les commandes à faire au bar");
// }
private void displayGestionPersonnelMenu() {
System.out.println("\n\n\n\n\n\n\n\n\n\n\n\n\n\n");
System.out.println("0- Retour");
System.out.println("1- Affichage liste employés");
System.out.println("2- Distribution des tables");
System.out.println("3- Ajouter serveur");
System.out.println("4- Ajouter cuisinier");
System.out.println("5- Ajouter barman");
}
}