-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPain.java
102 lines (77 loc) · 1.72 KB
/
Pain.java
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
/**
* Cas particulier de {@link Consommable} ayant une forme specifique
* Pain est {@link Refaisable} : le stock de pains peut etre reassorti
*/
public class Pain extends Consommable implements Refaisable {
/**
* Attribut et compteur
*/
private String forme;
private static int cptP = 0;
/**
* Constructeur
*
* @param n : nom
* @param p : prix
* @param x : abscisse
* @param y : ordonnee
* @param f : forme
*/
public Pain (String n, double p, int x, int y, String f) {
super(n, p, x, y);
forme = f;
cptP++;
}
/**
* Redefinition de la methode standard toString()
*
* @return les caracteristiques du pain
*/
@Override
public String toString() {
return "Pain : " + forme + ", " + super.toString();
}
/**
* Redefinition de la methode standard equals()
*
* @return l'egalite stricturelle entre deux pains
*/
@Override
public boolean equals(Object obj) {
if ((this.getClass() == obj.getClass()) && (this != null)) {
Pain p = (Pain) obj;
return super.equals(obj) && (forme == p.forme);
}
return false;
}
/**
* Redefinition de la methode refaire() de l'interface {@link Refaisable}
*
* @param tab : le tableau de pains a remplir
*/
@Override
public void refaire() {
Boulangerie b = Boulangerie.getBoulangerie(0, 0, 0, 0, 0);
b.remplirPains();
}
/**
* Accesseur
*/
public static int getCptP() {
return cptP;
}
/**
* Mutateur
*/
public static void setCptP(int n) {
cptP = n;
}
/**
* Redefinition de la methode abstraite clone()
*
* @return un pain identique
*/
public Pain clone() {
return new Pain(this.getNom(), this.getPrix(), this.getX(), this.getY(), forme);
}
}