The goal of this lab period is to get you started on the current assignment and give you an introduction to Interfaces.
Documentation for Java 1.5 is located at: Java 1.5 SE API.
Documentation for Java 1.6 is located at: Java 1.6 SE API
Think about the concept of an inventory. What are the things an inventory needs to do?
- Stock - put things into the inventory
- Consume - take things out of the inventory
- Query - discover what is in the inventory
An interface allows us to specify a set of methods a class must implement in order to qualify as a member of that type.
- Create a Stuff class that has a string descriptor (name) and a quantity (amount), and give it some accessor methods.
- Create an inventory interface: just the three method descriptors: Stock, Consume, and Query. What should their input and output forms be?
- Create a class Backpack that implements the inventory interface. It should be able to hold up to five things (Stuff). You can use the skeleton file to get started.
Once you are comfortable with the above tasks, go on to the assignment.