repositories
/
TP_POO.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
3b61f2e
)
TP2: Simplify the compacter method in the image class.
author
Jérôme Benoit
<jerome.benoit@piment-noir.org>
Sun, 4 Mar 2018 22:23:07 +0000
(23:23 +0100)
committer
Jérôme Benoit
<jerome.benoit@piment-noir.org>
Sun, 4 Mar 2018 22:23:07 +0000
(23:23 +0100)
Signed-off-by: Jérôme Benoit <jerome.benoit@piment-noir.org>
TP2/Image.java
patch
|
blob
|
blame
|
history
diff --git
a/TP2/Image.java
b/TP2/Image.java
index 37bc6c3fc4d6b724c94db174b78f3e3bd79a8670..8289930d309e5e9f9bb18b5014386ac55b5b4f1d 100644
(file)
--- a/
TP2/Image.java
+++ b/
TP2/Image.java
@@
-67,9
+67,16
@@
class Image extends Forme implements Compactable {
}
public void compacter(int nElements) {
- int minIndex = formeNumber - nElements - 1;
+ // Heavy solution
+ /* int minIndex = formeNumber - nElements - 1;
for (int i = formeNumber - 1; (i > minIndex && !isEmpty()); i--) {
supprimer(i);
+ } */
+ // Lightweight solution
+ if (formeNumber - nElements > 0) {
+ formeNumber -= nElements;
+ } else {
+ formeNumber = 0;
}
}