I have to code this UML that is linking 2 classes: Product (not visible) and ShoppingCart
I've declared the 2 variables clientName and total and have started to create the constructor. In the formulation of the exercise it's mentioned that "cart" has to be declared as type List (static) and will be built as ArrayList (dynamic) using the default's constructor.
I am not sure how to declare it, and I'm also not sure how to create the getCart() method. I don't know where the array ShoppingCart[] comes from as I have not declared it.
This is the code I've created so far:
import java.util.ArrayList; import java.util.List;
public class ShoppingCart {
private String clientName;
private double total;
private List<String> cart;
public ShoppingCart(String clientName){
setClientName(clientName);
List<String> cart = new ArrayList<String>();
}
public ShoppingCart[] getCart(){
return cart;
}
Thanks in advance
