Thanks so much for your help. Just want to check that I understand you correctly and have implemented this properly. I have made the following code which works fine. Are there any improvements to my code you would suggest or am I now going down the right track?
order.java
PHP Code:
import java.util.ArrayList;
public class order {
String orderStatus;
double subtotal;
ArrayList<product> products = new ArrayList<product>();
public order() {
orderStatus="local";
}
public void addProduct(int SKU, double price, String name) {
products.add(new product(SKU, price, name));
subtotal=subtotal+price;
}
public void removeProduct(product productToRemove) {
subtotal=subtotal-productToRemove.getPrice();
products.remove(productToRemove);
}
}
product.java
PHP Code:
public class product {
int SKU;
double price;
String name;
public product(int SKU, double price, String name) {
this.SKU=SKU;
this.price=price;
this.name=name;
}
public double getPrice() {
return price;
}
}
Thanks for your help.