-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSucrerie.java
113 lines (85 loc) · 1.97 KB
/
Sucrerie.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
103
104
105
106
107
108
109
110
111
112
113
/**
* Cas particulier de {@link Consommable} possedant un certain gout
* Sucrerie est {@link Refaisable} : reapprovisionnement possible
*/
public class Sucrerie extends Consommable implements Refaisable {
/**
* Attribut et compteur
*/
private String gout;
private static int cptS = 0;
/**
* Constructeur
*
* @param n : nom
* @param p : prix
* @param x : abscisse
* @param y : ordonnee
* @param g : gout
*/
public Sucrerie (String n, double p, int x, int y, String g) {
super(n, p, x, y);
gout = g;
cptS++;
}
/**
* Redefinition de la methode standard toString()
*
* @return les caracteristiques d'une sucrerie
*/
@Override
public String toString() {
return "Sucrerie : " + gout + ", " + super.toString();
}
/**
* Redefinition de la methode standard equals()
*
* @return l'egalite structurelle entre deux sucreries
*/
@Override
public boolean equals(Object obj) {
if ((this.getClass() == obj.getClass()) && (this != null)) {
Sucrerie s = (Sucrerie) obj;
return super.equals(obj) && (gout == s.gout);
}
return false;
}
/**
* Redefinition de la methode refaire() de l'interface Refaisable
*
* @param tab : tableau de sucreries a remplir
*/
@Override
public void refaire() {
Boulangerie b = Boulangerie.getBoulangerie(0, 0, 0, 0, 0);
b.remplirSucreries();
}
/*
* Factory permettant la creation simplifiee d'une sucrerie
*
* @return une sucrerie predefinie
*/
public static Sucrerie make() {
return new Sucrerie ("Paquet de carambars", 2.44, 0, 0, "Citron");
}
/*
* Accesseur
*/
public static int getCptS() {
return cptS;
}
/*
* Mutateur
*/
public static void setCptS(int n) {
cptS = n;
}
/**
* Redefinition de la methode abstraite clone()
*
* @return une sucrerie identique
*/
public Sucrerie clone() {
return new Sucrerie(this.getNom(), this.getPrix(), this.getX(), this.getY(), gout);
}
}