I have a example and I'm course how approach this problem. Logically how would approach this problem.
?
Exercise 04 Write a class, called ShoppingList, which encapsulates a shopping list. The attributes for this class are: the owner's name String an array of items, list String - size TBD an integer, count int - to keep track of the # of items on the list The constructor should take a String and an int as the parameters this is the person's name and the maximum size of the list. Use the max size to instantiate the list (new String [size] ). count should be set to 0. In addition to the constructor, there should be an accessor for the size {list . length], for the count of items on the list, and for the list owner's name. There should also be a method public void addI tern (String item) which adds one item to the list. This should also increment the count. If the count is == size when addI tem is called, the list is full. Print an error message and terminate the program. Finally, we need a public String toString() method that returns a string with all of the items on the list, one per line. Use the same technique used with toString for MonthlyRain, above. Also, write a class, TestList, that tests this shopping list out. Have TestList manage a dialog with the user, such as: Enter your name: Martha Enter an icem for the list: Tomatoes Enter an icem for the list: Bread Enter an item for the list: Milk Enter an i:em for the list: Martha's shopping list is: Tomatoes Bread Milk In the above, the usel's input is represented in hold to differentiate it from the program's output. When the name (Martha) is read in, the ShoppingList is instantiated. Use 10 as the maximum size of the list. Also, the sentinel for "no more items\" is an item that is the empty string {just press Enter when prompted for an item for the list]. This is a String, read in with the nextLine {) method of the Scanner. Test for it to be equal to the empty string with if (item. equals ("")) { // remember, do NOT use =2 with Strings where 'item' is the String that was read in. Remember, do NOT use '==' with Strings