I am trying to get the arrays 't','p' and 's' from the class 'BuildOrder' to another class. Here is the code for reference:
I tried to create methods to return them and retrieve them in another class but I am out of ideas how to do it.
package composite;
public class BuildOrder {
String[] t;
String[] p;
String[] s;
public static Component getOrder()
{
Composite order = new Composite( "Order" ) ;
order.addChild(new Leaf("Crispy Onion Strings", 5.50 ));
order.addChild(new Leaf("The Purist", 8.00 ));
//Composite customBurger = new Composite( "Build Your Own Burger" ) ;
String[] t={"Bermuda Red Onion","Black Olives","Carrot Strings","Coleslaw"};
String[] p={"Applewood Smoked Bacon"};
String[] s={"Apricot Sauce"};
/*customBurger.addChild(new Leaf("Beef, 1/3 lb on a Bun",9.50 )); // base price for 1/3 lb
customBurger.addChild(new Leaf("Danish Blue Cheese", 0.00 )); // 1 cheese free, extra cheese +1.00
customBurger.addChild(new Leaf("Horseradish Cheddar", 1.00 )); // extra cheese +1.00
customBurger.addChild(new Leaf("Bermuda Red Onion", 0.00 )); // 4 toppings free, extra +.75
customBurger.addChild(new Leaf("Black Olives", 0.00 )); // 4 toppings free, extra +.75
customBurger.addChild(new Leaf("Carrot Strings", 0.00 )); // 4 toppings free, extra +.75
customBurger.addChild(new Leaf("Coleslaw", 0.00 )); // 4 toppings free, extra +.75
customBurger.addChild(new Leaf("Applewood Smoked Bacon", 1.50 )); // premium topping +1.50
customBurger.addChild(new Leaf("Apricot Sauce", 0.00 )); // 1 sauce free, extra +.75
order.addChild( customBurger );*/
return order ;
}
public String gettoppings(String t)
{ return t;
}
public String getpremium(String p)
{ return p;
}
public String getSauces(String s)
{ return s;
}
}
//following is the class where I want to use the above strings public class Sauce implements LeafDecorator { public String Sauce() { BuildOrder bo=new BuildOrder(); String order=bo.getSauces(String t);
}
}
Aucun commentaire:
Enregistrer un commentaire