10A

In this problem you will write several static methods to work with arrays and ArrayLists. Remember that a static method does not work on the instance variables of the class. All the data needed is provided in the parameters. Call the class Util. Notice how the methods are invoked in UtilTester.

For the draft, implement the max method

10A draft:
10A final:

10B

In this problem you will implement a solution using the design pattern for collecting objects. We are going to model a bookstore's inventory of books. A BookStoreInventory uses an ArrayList to keep track of Book objects. You will write both a BookStoreInventory class and a Book class.

A Book has a title and a price. Provide a constructor that takes title and price, in that order. Provide getters and setters for the instance variables. This is the design pattern for managing properties of objects.

A BookStoreInventory has a constructor.

It has methods

Provide Javadoc for both classes. Look at the documentation produced for BookStoreInventory. The Javadoc utility works on static methods, too.

For the draft, implement the Book class

10B draft:
10B final:

10C

In the TrafficLight class from hw3c, all three lights were always on. In this problem, you are going to modify the class to maintain the state of traffic light. Maintaining state is one of the design pattern discussed in this week's lesson. The state of the TrafficLight is which light is lit. It changes every time the TrafficLight cycles.

Define an instance variable to hold the state (which light is lit). Make it an int. And define public constants for red. yellow, and green named RED, YELLOW, GREEN (These will be ints also)

In the constructor, set the state of the light to red (using the constant).

Provide methods

 

Output of final will look like this

Provide Javadoc

For the draft, provide: the instance variable to keep track of current state, the constants, and the getLight method. Update the constructor to set the state to RED. Provide Javadoc.

10C draft:
10C final: