could some one explain the code below
import java.util.Map;
import java.util.HashMap;
import java.util.Collection;
import java.util.ArrayList;
final class InventorySet {
/** @invariant <code>_data != null</code> */
private final Map<VideoObj,Record> _data = new HashMap<VideoObj,Record>();
InventorySet() { }
/**
* Return the number of Records.
*/
public int size() {
// fill in the code
return 0;
}
public Record get(VideoObj v) {
// fill in the code
return null;
}
public Collection<Record> toCollection() {
// Recall that an ArrayList is a Collection.
// TODO
return null;
}
/**
* Add or remove copies of a video from the inventory.
* If a video record is not already present (and change is
* positive), a record is created.
* If a record is already present, <code>numOwned</code> is
* modified using <code>change</code>.
* If <code>change</code> brings the number of copies to be zero,
* the record is removed from the inventory.
* @param video the video to be added.
* @param change the number of copies to add (or remove if negative).
* @throws IllegalArgumentException if video null, change is zero,
* if attempting to remove more copies than are owned, or if
* attempting to remove copies that are checked out.
* @postcondition changes the record for the video
*/
public void addNumOwned(VideoObj video, int change) {
// TODO
}
/**
* Check out a video.
* @param video the video to be checked out.
* @throws IllegalArgumentException if video has no record or numOut
* equals numOwned.
* @postcondition changes the record for the video
*/
public void checkOut(VideoObj video) {
// TODO
}
/**
* Check in a video.
* @param video the video to be checked in.
* @throws IllegalArgumentException if video has no record or numOut
* non-positive.
* @postcondition changes the record for the video
*/
public void checkIn(VideoObj video) {
// TODO
}
/**
* Remove all records from the inventory.
* @postcondition <code>size() == 0</code>
*/
public void clear() {
// fill in the code
}
public String toString() {
StringBuilder buffer = new StringBuilder();
buffer.append("Database:\n");
for (Record r : _data.values()) {
buffer.append(" ");
buffer.append(r);
buffer.append("\n");
}
return buffer.toString();
}
}
thanks in advance