Return ArrayList function - Java
Interface - Product
Code:
package fpt.com;
import java.io.Serializable;
public interface Product extends Serializable {
long getId();
double getPrice();
}
Interface - ProducktList
Code:
package fpt.com;
import java.io.Serializable;
import java.util.List;
public interface ProductList extends List<Product> , Serializable {
@Override
boolean add(Product e);
}
Interface - Order
Code:
package fpt.com;
public interface Order extends ProductList {
/**
* @return The ProductList of the Order
*/
ProductList getProducts();
}
Class - ProductList
Code:
import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;
import java.util.List;
import java.util.ListIterator;
import fpt.com.Product;
public class ProductList extends ArrayList<Product> implements fpt.com.ProductList{
public boolean add(Product e)
{
super.add(e);
return true;
}
}
Class - Order
Code:
import java.util.ArrayList;
import fpt.com.Product;
import fpt.com.ProductList;
public class Order extends ArrayList<Product> implements fpt.com.Order {
/**
* @return The ProductList of the Order
*/
public ProductList getProducts()
{
}
My question is: How to write the function getProducts() in the class Order. I want the function to return the list of products,but i have no idea how to implement this function.I know that it is something very trivial,but I don't know hot to do it.