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 pathJournee.java
More file actions
105 lines (87 loc) · 5.1 KB
/
Journee.java
File metadata and controls
105 lines (87 loc) · 5.1 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
import java.util.ArrayList;
public class Journee {
protected ArrayList<Table> listeDesTables = new ArrayList<Table>();
public int hOuverture;
public int hFermeture;
protected Facture factureJournee = new Facture();
public ArrayList<Table> getListeDesTables() { return this.listeDesTables; }
public Journee(int hOuverture,int hFermeture){
this.hFermeture=hFermeture;
this.hOuverture=hOuverture;
}
public int conduireATable(int nbClient) {
boolean tableIdeale = false; // On utilise ce boolean pour trouver la table la plus adapaté au nombre de clients
for (int numTable = 0; numTable < listeDesTables.size(); numTable++) {
// Si on trouve une table non occupe et avec le nombre exact de place necessaire
if (listeDesTables.get(numTable).isTableOccupee() == false && listeDesTables.get(numTable).getNbClientMax() == nbClient && tableIdeale == false) {
this.listeDesTables.get(numTable).setTableOccupee(true); // On dit que cette table est desormais occupée
tableIdeale = true;
numTable++;
System.out.println("\nAller à la table n°" + numTable);
//TEST QUI AFFICHE LA LISTE DES TABLES AVEC LEURS NOMBRE DE PLACE MAXIMUM
// for (Table tabli : getListeDesTables()) {
// System.out.println("table n°" + tabli.getNumeroTable() + " | " + tabli.getNbClientMax() + " | " + tabli.isTableOccupee());
// }
return numTable;
}
}
// si on n'a pas su trouver la table parfaite, on cherche une table avec le moins de place en trop possible
if (tableIdeale == false) {
for (int numTable = 0; numTable < listeDesTables.size(); numTable++) {
// Si on trouve une table non occupe et avec 2 places au max en trop
if (listeDesTables.get(numTable).isTableOccupee() == false && listeDesTables.get(numTable).getNbClientMax() <= nbClient + 2 && tableIdeale == false) {
this.listeDesTables.get(numTable).setTableOccupee(true); // On dit que cette table est desormais occupe
tableIdeale = true;
numTable++;
System.out.println("Aller à la table n°" + numTable);
//TEST QUI AFFICHE LA LISTE DES TABLES AVEC LEURS NOMBRE DE PLACE MAXIMUM
// for (Table tabli : getListeDesTables()) {
// System.out.println("table n°" + tabli.getNumeroTable() + " | " + tabli.getNbClientMax() + " | " + tabli.isTableOccupee());
// }
return numTable;
}
}
}
// si on n'a toujours pas trouvé de table adapté, on continue
if (tableIdeale == false) {
for (int numTable = 0; numTable < listeDesTables.size(); numTable++) {
// Si on trouve une table non occupe et avec 4 places au max en trop
if (listeDesTables.get(numTable).isTableOccupee() == false && listeDesTables.get(numTable).getNbClientMax() <= nbClient + 4 && tableIdeale == false) {
this.listeDesTables.get(numTable).setTableOccupee(true); // On dit que cette table est desormais occupe
tableIdeale = true;
numTable++;
System.out.println("Aller à la table n°" + numTable);
//TEST QUI AFFICHE LA LISTE DES TABLES AVEC LEURS NOMBRE DE PLACE MAXIMUM
// for (Table tabli : getListeDesTables()) {
// System.out.println("table n°" + tabli.getNumeroTable() + " | " + tabli.getNbClientMax() + " | " + tabli.isTableOccupee());
// }
return numTable;
}
}
}
// dernier essai
if (tableIdeale == false) {
for (int numTable = 0; numTable < listeDesTables.size(); numTable++) {
// Si on trouve une table non occupe et avec 6 places au max en trop
if (listeDesTables.get(numTable).isTableOccupee() == false && listeDesTables.get(numTable).getNbClientMax() <= nbClient + 6 && tableIdeale == false) {
this.listeDesTables.get(numTable).setTableOccupee(true); // On dit que cette table est desormais occupe
tableIdeale = true;
numTable++;
System.out.println("Aller à la table n°" + numTable);
//TEST QUI AFFICHE LA LISTE DES TABLES AVEC LEURS NOMBRE DE PLACE MAXIMUM
for (Table tabli : getListeDesTables()) {
System.out.println("table n°" + tabli.getNumeroTable() + " | " + tabli.getNbClientMax() + " | " + tabli.isTableOccupee());
}
return numTable;
}
}
}
// si on n'a pas trouvé de table, c'est qu'il n'y en a pas de disponible ...
System.err.println("Il n'y a plus de table disponible.");
return 0;
}
protected void nettoyage(){
}
protected void ajoutTable(){
}
}