project1
Class ProductItemGroup

java.lang.Object
  |
  +--project1.ProductId
        |
        +--project1.ProductItem
              |
              +--project1.ProductItemGroup
All Implemented Interfaces:
java.util.Collection

public class ProductItemGroup
extends ProductItem
implements java.util.Collection

ProductItemGroup class is used to create product trees of mixed child entities.


Field Summary
 
Fields inherited from class project1.ProductItem
name
 
Constructor Summary
ProductItemGroup()
          Constructor
ProductItemGroup(java.util.Collection o)
          Constructor
ProductItemGroup(java.lang.String isim)
          Constructor
 
Method Summary
 boolean add(java.lang.Object obj)
           
 boolean addAll(java.util.Collection collection)
           
 void addProduct(ProductItem p)
          Method
 void addProduct(ProductItemGroup p)
          Method
 void clear()
           
 boolean contains(java.lang.Object obj)
           
 boolean containsAll(java.util.Collection collection)
           
 boolean isEmpty()
           
 java.util.Iterator iterator()
           
 void manufactureProduct(int amount)
          Method
 boolean prepareForManufacture(int amount)
          Method
 void printGroup()
          Method prints the whole product tree
 void printGroup(ProductItemGroup pp)
          Method
 boolean remove(java.lang.Object obj)
           
 boolean removeAll(java.util.Collection collection)
           
 void removeProduct(ProductItem p)
          Method
 void removeProduct(ProductItemGroup pp)
          Method
 boolean retainAll(java.util.Collection collection)
           
 int size()
           
 java.lang.Object[] toArray()
           
 java.lang.Object[] toArray(java.lang.Object[] obj)
           
 
Methods inherited from class project1.ProductItem
changeBegValid, changeEndValid
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface java.util.Collection
equals, hashCode
 

Constructor Detail

ProductItemGroup

public ProductItemGroup()
Constructor


ProductItemGroup

public ProductItemGroup(java.lang.String isim)
Constructor

Parameters:
isim - sets the name

ProductItemGroup

public ProductItemGroup(java.util.Collection o)
Constructor

Parameters:
o - adds o to the product tree, where o is another product tree
Method Detail

addProduct

public void addProduct(ProductItem p)
Method

Parameters:
p - add this product

addProduct

public void addProduct(ProductItemGroup p)
Method

Parameters:
p - add this product tree

prepareForManufacture

public boolean prepareForManufacture(int amount)
Method

Parameters:
amount - prepare manufacture of this amount of product, using the product tree In the project documentation, we were asked to both return false and throw an exception. Although, I implemented both, since we can not realize both, I choose returning false. This method should check that for each type=4 product in the productgroup, there is enough in the stock to produce the given amount. If for any productItem, there is not enough stock, it should give an exception error and return false; otherwise it should return true;

manufactureProduct

public void manufactureProduct(int amount)
Method

Parameters:
amount - produce by the specified amount This method first checks if the associated machine is ready – if so manufactures the given productgroup by the given amount. In doing so, it decreases the stock amounts of all the used components by the given amount and increases the stock amount of the produced product by the given given amount.

removeProduct

public void removeProduct(ProductItem p)
Method

Parameters:
p - remove product p from the product tree

removeProduct

public void removeProduct(ProductItemGroup pp)
Method


printGroup

public void printGroup()
Method prints the whole product tree


printGroup

public void printGroup(ProductItemGroup pp)
Method

Parameters:
pp - print the sub-product tree pp

add

public boolean add(java.lang.Object obj)
Specified by:
add in interface java.util.Collection

addAll

public boolean addAll(java.util.Collection collection)
Specified by:
addAll in interface java.util.Collection

clear

public void clear()
Specified by:
clear in interface java.util.Collection

contains

public boolean contains(java.lang.Object obj)
Specified by:
contains in interface java.util.Collection

containsAll

public boolean containsAll(java.util.Collection collection)
Specified by:
containsAll in interface java.util.Collection

isEmpty

public boolean isEmpty()
Specified by:
isEmpty in interface java.util.Collection

iterator

public java.util.Iterator iterator()
Specified by:
iterator in interface java.util.Collection

remove

public boolean remove(java.lang.Object obj)
Specified by:
remove in interface java.util.Collection

removeAll

public boolean removeAll(java.util.Collection collection)
Specified by:
removeAll in interface java.util.Collection

retainAll

public boolean retainAll(java.util.Collection collection)
Specified by:
retainAll in interface java.util.Collection

size

public int size()
Specified by:
size in interface java.util.Collection

toArray

public java.lang.Object[] toArray()
Specified by:
toArray in interface java.util.Collection

toArray

public java.lang.Object[] toArray(java.lang.Object[] obj)
Specified by:
toArray in interface java.util.Collection