2015-05-31 11:55:18 +03:00
|
|
|
package com.iluwatar.privateclassdata;
|
2015-05-23 15:52:50 +03:00
|
|
|
|
2015-05-23 16:07:04 +03:00
|
|
|
/**
|
|
|
|
*
|
|
|
|
* Immutable stew class, protected with Private Class Data pattern
|
|
|
|
*
|
|
|
|
*/
|
2015-05-23 15:52:50 +03:00
|
|
|
public class ImmutableStew {
|
|
|
|
|
2015-11-01 21:29:13 -05:00
|
|
|
private StewData data;
|
|
|
|
|
|
|
|
public ImmutableStew(int numPotatoes, int numCarrots, int numMeat, int numPeppers) {
|
|
|
|
data = new StewData(numPotatoes, numCarrots, numMeat, numPeppers);
|
|
|
|
}
|
|
|
|
|
2015-12-25 23:49:28 +02:00
|
|
|
/**
|
|
|
|
* Mix the stew
|
|
|
|
*/
|
2015-11-01 21:29:13 -05:00
|
|
|
public void mix() {
|
|
|
|
System.out.println(String.format(
|
|
|
|
"Mixing the immutable stew we find: %d potatoes, %d carrots, %d meat and %d peppers",
|
|
|
|
data.getNumPotatoes(), data.getNumCarrots(), data.getNumMeat(), data.getNumPeppers()));
|
|
|
|
}
|
2015-05-23 15:52:50 +03:00
|
|
|
}
|