mirror of
https://github.com/tiennm99/java-design-patterns.git
synced 2026-05-15 14:59:25 +00:00
Reformat rest of the design patterns - Issue #224
This commit is contained in:
@@ -6,37 +6,38 @@ package com.iluwatar.privateclassdata;
|
||||
*
|
||||
*/
|
||||
public class Stew {
|
||||
|
||||
private int numPotatoes;
|
||||
private int numCarrots;
|
||||
private int numMeat;
|
||||
private int numPeppers;
|
||||
|
||||
public Stew(int numPotatoes, int numCarrots, int numMeat, int numPeppers) {
|
||||
this.numPotatoes = numPotatoes;
|
||||
this.numCarrots = numCarrots;
|
||||
this.numMeat = numMeat;
|
||||
this.numPeppers = numPeppers;
|
||||
}
|
||||
|
||||
public void mix() {
|
||||
System.out.println(String.format("Mixing the stew we find: %d potatoes, %d carrots, %d meat and %d peppers",
|
||||
numPotatoes, numCarrots, numMeat, numPeppers));
|
||||
}
|
||||
|
||||
public void taste() {
|
||||
System.out.println("Tasting the stew");
|
||||
if (numPotatoes > 0) {
|
||||
numPotatoes--;
|
||||
}
|
||||
if (numCarrots > 0) {
|
||||
numCarrots--;
|
||||
}
|
||||
if (numMeat > 0) {
|
||||
numMeat--;
|
||||
}
|
||||
if (numPeppers > 0) {
|
||||
numPeppers--;
|
||||
}
|
||||
}
|
||||
|
||||
private int numPotatoes;
|
||||
private int numCarrots;
|
||||
private int numMeat;
|
||||
private int numPeppers;
|
||||
|
||||
public Stew(int numPotatoes, int numCarrots, int numMeat, int numPeppers) {
|
||||
this.numPotatoes = numPotatoes;
|
||||
this.numCarrots = numCarrots;
|
||||
this.numMeat = numMeat;
|
||||
this.numPeppers = numPeppers;
|
||||
}
|
||||
|
||||
public void mix() {
|
||||
System.out.println(String.format(
|
||||
"Mixing the stew we find: %d potatoes, %d carrots, %d meat and %d peppers", numPotatoes,
|
||||
numCarrots, numMeat, numPeppers));
|
||||
}
|
||||
|
||||
public void taste() {
|
||||
System.out.println("Tasting the stew");
|
||||
if (numPotatoes > 0) {
|
||||
numPotatoes--;
|
||||
}
|
||||
if (numCarrots > 0) {
|
||||
numCarrots--;
|
||||
}
|
||||
if (numMeat > 0) {
|
||||
numMeat--;
|
||||
}
|
||||
if (numPeppers > 0) {
|
||||
numPeppers--;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user