Created
April 18, 2022 10:18
-
-
Save liampulles/dfc95496fdc6d82f489abc96e4736ad2 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// IsAvailable will return true if the inventory item may | |
// be checked out - false otherwise. | |
func (i *InventoryItemImpl) IsAvailable() bool { | |
return i.available | |
} | |
// Checkout will mark the inventory item as unavilable. | |
// If the inventory item is not available, | |
// then an error is returned. | |
func (i *InventoryItemImpl) Checkout() error { | |
if !i.available { | |
return fmt.Errorf("cannot check out inventory item - it is unavailable") | |
} | |
i.available = false | |
return nil | |
} | |
// CheckIn will mark the inventory item as available. | |
// If the inventory item is available, then an | |
// error is returned. | |
func (i *InventoryItemImpl) CheckIn() error { | |
if i.available { | |
return fmt.Errorf("cannot check in inventory item - it is already checked in") | |
} | |
i.available = true | |
return nil | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment