} else if (customers.length <= n) {
int customerMax = customers[0];
for (int i = 0; i < n; i++) {
if (customers[i] > customerMax) {
customerMax = customers[i];
}
}
return customerMax;
}
private TextView createOrderSummary(View view){
EditText nameField = findViewById(R.id.name_field);
String name = nameField.getText().toString();
CheckBox whippedCreamCheckBox = findViewById(R.id.whipped_cream_checkbox);
hasWhippedCream = whippedCreamCheckBox.isChecked();
CheckBox chocolateCheckBox = findViewById(R.id.chocolate_checkbox);
hasChocolate = chocolateCheckBox.isChecked();
TextView priceMessage = findViewById(R.id.price_text_view);
if (numberOfCoffees == 0) {
textString = getString(R.string.total_coffee_cost_zero, name);
priceMessage.setText(textString);
}
else if ((numberOfCoffees == 1) && (!hasWhippedCream) && (!hasChocolate)) {
textString = getString(R.string.total_coffee_cost_one, name, numberOfCoffees, numberOfCoffees * priceOfCup);
priceMessage.setText(textString);
}
else if ((numberOfCoffees == 1) && (hasWhippedCream) && (!hasChocolate)) {
textString = getString(R.string.total_coffee_cost_one_whipped_cream, name, numberOfCoffees, numberOfCoffees * priceOfCup);
priceMessage.setText(textString);
}
else if ((numberOfCoffees == 1) && (!hasWhippedCream) && (hasChocolate)) {
textString = getString(R.string.total_coffee_cost_one_chocolate, name, numberOfCoffees, numberOfCoffees * priceOfCup);
priceMessage.setText(textString);
}
else if ((numberOfCoffees == 1) && (hasWhippedCream) && (hasChocolate)) {
textString = getString(R.string.total_coffee_cost_one_cream_chocolate, name, numberOfCoffees, numberOfCoffees * priceOfCup);
priceMessage.setText(textString);
}
else if ((numberOfCoffees > 1) && (!hasWhippedCream) && (!hasChocolate)) {
textString = getString(R.string.total_coffee_cost, name, numberOfCoffees, numberOfCoffees * priceOfCup);
priceMessage.setText(textString);
}
else if ((numberOfCoffees > 1) && (hasWhippedCream) && (!hasChocolate)) {
textString = getString(R.string.total_coffee_cost_whipped_cream, name, numberOfCoffees, numberOfCoffees * priceOfCup);
priceMessage.setText(textString);
}
else if ((numberOfCoffees > 1) && (!hasWhippedCream) && (hasChocolate)) {
textString = getString(R.string.total_coffee_cost_chocolate, name, numberOfCoffees, numberOfCoffees * priceOfCup);
priceMessage.setText(textString);
}
else if ((numberOfCoffees > 1) && (hasWhippedCream) && (hasChocolate)) {
textString = getString(R.string.total_coffee_cost_cream_chocolate, name, numberOfCoffees, numberOfCoffees * priceOfCup);
priceMessage.setText(textString);
}
return priceMessage;
}