public class Data extends java.lang.Object
Modifier | Constructor and Description |
---|---|
private |
Data() |
Modifier and Type | Method and Description |
---|---|
static Command |
newAddCmd(Inventory inventory,
Video video,
int change)
Returns a command to add or remove copies of a video from the inventory.
|
static Command |
newClearCmd(Inventory inventory)
Returns a command to remove all records from the inventory.
|
static Command |
newInCmd(Inventory inventory,
Video video)
Returns a command to check in a video.
|
static Inventory |
newInventory()
Returns a new Inventory.
|
static Command |
newOutCmd(Inventory inventory,
Video video)
Returns a command to check out a video.
|
static Video |
newVideo(java.lang.String title,
int year,
java.lang.String director)
Factory method for Video objects.
|
private Data()
public static final Inventory newInventory()
public static Video newVideo(java.lang.String title, int year, java.lang.String director)
java.lang.IllegalArgumentException
- if Video invariant violated.public static Command newAddCmd(Inventory inventory, Video video, int change)
The returned command has the following behavior:
numOwned
is
modified using change
.change
brings the number of copies to be less
than one, the record is removed from the inventory.video
- the video to be added.change
- the number of copies to add (or remove if negative).java.lang.IllegalArgumentException
- if inventory
not created by a call to newInventory
.public static Command newOutCmd(Inventory inventory, Video video)
video
- the video to be checked out.public static Command newInCmd(Inventory inventory, Video video)
video
- the video to be checked in.public static Command newClearCmd(Inventory inventory)