You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
21 lines
457 B
Java
21 lines
457 B
Java
4 years ago
|
import common.Product;
|
||
|
import common.Supplier;
|
||
|
|
||
|
import java.util.HashSet;
|
||
|
import java.util.Iterator;
|
||
|
import java.util.Set;
|
||
|
|
||
|
public class ProductCatalogue implements Iterable<Product> {
|
||
|
private final Set<Product> products = new HashSet<>();
|
||
|
|
||
|
public void addSupplier(final Supplier supplier) {
|
||
|
|
||
|
products.addAll(supplier.getProducts());
|
||
|
}
|
||
|
|
||
|
@Override
|
||
|
public Iterator<Product> iterator() {
|
||
|
return products.iterator();
|
||
|
}
|
||
|
}
|