Question: Please answer 9.11 in java text public GroceryItem String String name text; double price money public String getName ) f return name; H public String
text public GroceryItem String String name text; double price money public String getName ) f return name; H public String getPrice ) return pricej This class compiles, but its constructor does not function properly. Why not? Programming Practice 9.11 OOP is often used when the data inside the object must maintain special relationships. Consider a clock with hours, minutes, and seconds. When the number of seconds reaches 60, the number of minutes is increased by 1, and the number of seconds is reset to 0. When the number of minutes reaches 60, the numer of hours is increased by 1, and the number of seconds is reset to 0. When the number of hours reaches 13, it is reset to 1. AM and PM switch whenever the number of hours reaches 12. Define a Clock class with private int fields hours, minutes, and seconds and a boolean field PM. Write a constructor that initializes hours to 12, minutes and seconds to O, and PM to false. Write a mutator increment that adds 1 to seconds. This mutator should correctly handle all the k behavior described above. Write an accessor called toStringO that returns a nicely formatted ted AM" version of the time as a String. For example, the initial time would be returned as "12:00:00 Make sure you pad the output for seconds and minutes with an extra "O" if they are less than 10 9.12 Draw on any of your hobbies to come up with a collection of items, whether those items are books you like to read, athletes you follow, music you collecet, or anything else that is easy to classify. First crea a class that can describe one of these items with three to five attributes, For ermlthi attributes of a book might be author tit
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
