Skip to content

Commit 851fe4b

Browse files
committed
Work on the example.
1 parent b755424 commit 851fe4b

File tree

2 files changed

+41
-0
lines changed

2 files changed

+41
-0
lines changed

private-class-data/src/main/java/com/iluwatar/App.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,9 @@
33
public class App {
44

55
public static void main( String[] args ) {
6+
Stew stew = new Stew(1, 2, 3, 4);
7+
stew.mix();
8+
stew.taste();
9+
stew.mix();
610
}
711
}
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
package com.iluwatar;
2+
3+
public class Stew {
4+
5+
private int numPotatoes;
6+
private int numCarrots;
7+
private int numMeat;
8+
private int numPeppers;
9+
10+
public Stew(int numPotatoes, int numCarrots, int numMeat, int numPeppers) {
11+
this.numPotatoes = numPotatoes;
12+
this.numCarrots = numCarrots;
13+
this.numMeat = numMeat;
14+
this.numPeppers = numPeppers;
15+
}
16+
17+
public void mix() {
18+
System.out.println(String.format("Mixing the stew we find: %d potatoes, %d carrots, %d meat and %d peppers",
19+
numPotatoes, numCarrots, numMeat, numPeppers));
20+
}
21+
22+
public void taste() {
23+
System.out.println("Tasting the stew");
24+
if (numPotatoes > 0) {
25+
numPotatoes--;
26+
}
27+
if (numCarrots > 0) {
28+
numCarrots--;
29+
}
30+
if (numMeat > 0) {
31+
numMeat--;
32+
}
33+
if (numPeppers > 0) {
34+
numPeppers--;
35+
}
36+
}
37+
}

0 commit comments

Comments
 (0)