My friend and I are studying for our programming exam doing the Sample Programming Exam, and are having trouble using an Array List as a parameter in a method to remove multiple items from an Array List in the same class.
We have tried searching the web and using our BlueJ textbook to find a solution.
The instruction on our assignment sheet says, "Write a method removeItemFromOrder with an array of strings itemArray parameter to remove multiple food items from the order."
import java.util.ArrayList;
/**
* Write a description of class Order here.
*
* @author (your name)
* @version (a version number or a date)
*/
public class Order
{
// instance variables - replace the example below with your own
private ArrayList<OrderedItem> order;
/**
* Constructor for objects of class Order
*/
public Order()
{
order = new ArrayList<>();
}
/**
* Returns the order collection to the user.
* @return the order collection.
*/
public ArrayList getOrder()
{
return order;
}
/**
* Add an item to the order.
* @param OrderedItem the item to be added
*/
public void addOrderItem(OrderedItem foodItem)
{
order.add(foodItem);
}
public void removeOrderItem(ArrayList<String> itemArray)
{
//**We don't know what to put here!**
}
}