📄 soup.java
字号:
package builder;
import java.util.*;
public abstract class Soup {
ArrayList soupIngredients = new ArrayList();
String soupName;
public String getSoupName() { return soupName; }
public String toString() {
StringBuffer stringOfIngredients = new StringBuffer(soupName);
stringOfIngredients.append(" Ingredients: ");
ListIterator soupIterator = soupIngredients.listIterator();
while (soupIterator.hasNext()){
stringOfIngredients.append((String)soupIterator.next());
}
return stringOfIngredients.toString();
}
}
class ChickenSoup extends Soup {
public ChickenSoup() {
soupName = "ChickenSoup";
soupIngredients.add("1 Pound diced chicken");
soupIngredients.add("1/2 cup rice");
soupIngredients.add("1 cup bullion");
soupIngredients.add("1/16 cup butter");
soupIngredients.add("1/4 cup diced carrots");
}
}
class ClamChowder extends Soup {
public ClamChowder() {
soupName = "ClamChowder";
soupIngredients.add("1 Pound Fresh Clams");
soupIngredients.add("1 cup fruit or vegetables");
soupIngredients.add("1/2 cup milk");
soupIngredients.add("1/4 cup butter");
soupIngredients.add("1/4 cup chips");
}
}
class FishChowder extends Soup {
public FishChowder() {
soupName = "FishChowder";
soupIngredients.add("1 Pound Fresh fish");
soupIngredients.add("1 cup fruit or vegetables");
soupIngredients.add("1/2 cup milk");
soupIngredients.add("1/4 cup butter");
soupIngredients.add("1/4 cup chips");
}
}
class Minnestrone extends Soup {
public Minnestrone() {
soupName = "Minestrone";
soupIngredients.add("1 Pound tomatos");
soupIngredients.add("1/2 cup pasta");
soupIngredients.add("1 cup tomato juice");
}
}
class Pastafazul extends Soup {
public Pastafazul() {
soupName = "Pasta fazul";
soupIngredients.add("1 Pound tomatos");
soupIngredients.add("1/2 cup pasta");
soupIngredients.add("1/2 cup diced carrots");
soupIngredients.add("1 cup tomato juice");
}
}
class TofuSoup extends Soup {
public TofuSoup() {
soupName = "Tofu Soup";
soupIngredients.add("1 Pound tofu");
soupIngredients.add("1 cup carrot juice");
soupIngredients.add("1/4 cup spirolena");
}
}
class VegetableSoup extends Soup {
public VegetableSoup() {
soupName = "Vegetable Soup";
soupIngredients.add("1 cup bullion");
soupIngredients.add("1/4 cup carrots");
soupIngredients.add("1/4 cup potatoes");
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -