Hi,
I am working on a program that has elements in an ArrayList in a ShoppingCart Class in a product package.
In Shopping Cart in the getItems method, I first created a list (required for assignment) in the getItems method List<Item> itemsList = new ArrayList(items);
I check this list for size and it matches my ArrayList items.
I also have my return return itemsList;
public List getItems()
{
List<Item> itemsList = new ArrayList(items);
//System.out.printf(" Total Price: %s\n", cPrice);
//clear();
return itemsList;
I need to to two things. First my Customer class in a different package I use a getCart method to access the getItems and then move the list as single element into a new list called bill.
I am unsure of how to code the getCart in my Customer class to get the list and move it to my Bill Class. Here is what I am currently trying.
public ShoppingCart getCart()
{
List<Bill> billList = new ArrayList();
billList = (List<Bill>) cart.getItems(); //(cart.getItems());
System.out.printf("\n billList Size: %d\n", billList.size());
return cart;
}
Any help would be appreciated.
Thanks