It's several years since I actually took a programming class. I know I can do what I'm thinking of, but I cannot remember the terms, so I cannot look it up.
I'm writing a mock application for a HMI class. It orders pizzas. Right now, I use a separate class to pass the values of the pizza between activities. (Values like toppings, pizza size, etc). The class is named pizzaApplication.class, and an example value would be pizzaApplication.chkPepperoni = true;
The way it's set up now, I can only have one pizza. I'd like to be able to have the pizzaApplication class setup to have more than one pizza. The code (from memory) would then end up looking similar to
pizzaApplication.pizzaOne(chkPepperoni = true);
So, two questions:
What is the exact terminology for this
What is the best way to increment the different objects I'd make? Ie
pizzaApplication.pizzaOne(chkPepperoni = true);
or
pizzaApplication.pizza.1(chkPepperoni = true);
Edit:
For further clarification, I'm writing an Android app. I first ask them to make their selections for their pizza, and save them to a a different java file, named PizzaApplication.java Here are the first lines of code.
public class PizzaApplication extends Application { private Order order = new Order();
//private final String[] toppings = new String[] { "Pepperoni", "Onion",
// "Sausage", "etc." };
public PizzaApplication() {
}
//Booleans for checking whether the individual pages have been completed.
Boolean vfTop = false;
Boolean vfAdd = false;
Boolean vfBill = false;
//Booleans for whether to add toppings
Boolean cheese = false;
Boolean italian = false;
Boolean pineapple = false;
Boolean ham = false;
Boolean pepperoni = false;
Boolean chicken = false;
//Globally accessible storage strings for various things
public String creditCard = "none";
public String crustType = "";
public String addressLine1 = "";
public String addressLine2 = "";
public String phoneNumber = "";
public String Toppings = "";
public Integer pizzaCount;
public String pizzaSize = "";
Now, here is some sample code from the Toppings class.
public class Toppings_Page extends Activity {
PizzaApplication pizzaApplication;
CheckBox Cheese, Ham, Italian, Pepperoni, Chicken, Pineapple;
Integer intpizzaCount;
TextView t;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_toppings__page);
pizzaApplication = (PizzaApplication) getApplication();
Cheese = (CheckBox)findViewById(R.id.chkCheese);
Italian = (CheckBox)findViewById(R.id.chkItalian);
Ham = (CheckBox)findViewById(R.id.chkHam);
Pepperoni = (CheckBox)findViewById(R.id.chkPepperoni);
Chicken = (CheckBox)findViewById(R.id.chkChicken);
Pineapple = (CheckBox)findViewById(R.id.chkPinapple);
and a little further down that class
public void onChecked(View view){
if (Cheese.isChecked()){pizzaApplication.cheese=true;}
else {pizzaApplication.cheese = false;}
if (Italian.isChecked()){pizzaApplication.italian=true;}
else {pizzaApplication.italian = false;}
if (Ham.isChecked()){pizzaApplication.ham=true;}
else {pizzaApplication.ham = false; }
if (Pepperoni.isChecked()){pizzaApplication.pepperoni=true;}
else {pizzaApplication.pepperoni = false;}
if (Chicken.isChecked()){pizzaApplication.chicken=true;}
else {pizzaApplication.chicken = false; }