Description
You will implement a class called BagOfPixels. The class should have exactly one field (the HashMap) and the following seven methods:
/**
* Initialize an empty bag with an initial capacity of 10.
* @postcondition
* This bag is empty and has an initial capacity of 10.
**/
public BagOfPixels()
{
}
/**
* Initialize an empty bag with a specified initial capacity.
* @param initialCapacity
* the initial capacity of this bag
* @precondition
* initialCapacity is non-negative.
* @postcondition
* This bag is empty and has the given initial capacity.
**/
public BagOfPixels(int initialCapacity)
{
}
/**
* Add a new intensity to this bag.
* @param pixel
* the new pixel’s intensity that is being inserted
* @postcondition
* A new copy of the pixel’s intensity has been added to this bag.
**/
public void add(double pixel)
{
}
/**
* Accessor method to count the number of occurrences of a particular
* pixel intensity in this bag.
* @param pixel
* the pixel intensity that needs to be counted
* @return
* the number of pixels in the bag with that intensity
**/
public int countOccurrences(double pixel)
{
return -1;
}
/**
* Remove one copy of a specified pixel intensity from this bag.
* @param pixel
* the pixel intensity to remove from the bag
* @postcondition
* If target was found in the bag, then one copy of
* target has been removed and the method returns true.
* Otherwise the bag remains unchanged and the method returns false.
* @return true if the target was successfully removed.
**/
public boolean remove(double pixel)
{
return false;
}
/**
* Determine the number of pixels in this bag.
* @return
* the number of pixels in this bag
**/
public int size()
{
return -1;
}
/**
* @return the average pixel intensity for the image represented by this
* BagOfPixels.
*/
public double averageIntensity()
{
return 0.0;
}
