私は別のリンクリストに追加しようとしているこれらすべての成分を含むこの現在のクラスを持っていますが、私は苦労しています。あるクラスから別のクラスへのLinkedListの特定の要素
import java.util.*;
public class Kitchen {
public static final Category CRUST = new Category("crust", 1, 1);
public static final Category SAUCE = new Category("sauce", 1, 1);
public static final Category TOPPING = new Category("topping", 2, 3);
private Category[] categories = { CRUST, SAUCE, TOPPING };
private LinkedList<Ingredient> ingredients = new LinkedList<Ingredient>();
public Kitchen() {
ingredients.add (new Ingredient("Thin", 3.00, CRUST));
ingredients.add (new Ingredient("Thick", 3.50, CRUST));
ingredients.add (new Ingredient("Tomato", 1.00, SAUCE));
ingredients.add (new Ingredient("Barbeque", 1.00, SAUCE));
ingredients.add (new Ingredient("Capsicum", 0.50, TOPPING));
ingredients.add (new Ingredient("Olives", 1.50, TOPPING));
ingredients.add (new Ingredient("Jalapenos", 1.00, TOPPING));
ingredients.add (new Ingredient("Beef", 2.75, TOPPING));
ingredients.add (new Ingredient("Pepperoni", 2.50, TOPPING));
}
これはすべての成分を含むクラスであり、これはいくつかの成分をコピーしようとしているクラスです。
import java.util.*;
import java.text.*;
public class Pizza {
private LinkedList<Ingredient> ingredients = new LinkedList<Ingredient>();
private int sold;
public void add(){
...
...
if (...);
ingredients.add(...);
...
}
キッチンの特定の成分をピザの成分に加えるにはどうすればいいですか?)私は材料自体を追加しようとしましたが、それはうまくいかないようです。 (inredients.add(成分))