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.
public static int max(int[] array) gets the maximum value in the arraypublic static boolean contains(String[] array, String target)determines if the target is in the array. Returns true if it is, otherwise returns falsepublic static ArrayList<String> wordsStartingWith(ArrayList<String> list, char letter)gets an ArrayList of all the words in the given ArrayList that start with the given letter. The comparison is case-insensitive. 'A' and 'a' are counted as the same letterFor the draft, implement the max method
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
add adds the specified book to the BookStoreInventoryremove removes the first book in the list with the specified title.contains determines if a book with a given title is in the BookStoreInventorylist gets an ArrayList of the Book titles in the BookStoreInventory. 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
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
public void cycle() changes the state (the color) in the following manner | If the state was | now it is |
|---|---|
| red | yellow |
| yellow | green |
| green | red |
public String getLight()gets the color (the state) of the light as a string "red", "yellow", or "green"| Color Name | On Color | Off RGB |
|---|---|---|
| red | Color.RED | 128,00,00 |
| yellow | Color.YELLOW | 255,165,00 |
| green | Color.GREEN | 85,107,47 |
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.