Create a new mutator called settime


Problem

Create a new mutator called setTime(). This mutator should take a single string parameter that consists of an hour number followed by "am" or "pm". It will set the field inside the Event by examining the characters of the string.

Implement this mutator method. First, you can use the substring() method provided by the String class to extract a new string containing all but the last two characters (i.e., just the digits). Then use the Integer.parseInt() static method to convert the digits into the corresponding int numeric value:

• String digitsOnly = theTime.substring(/* what goes here? */); int hour = Integer.parseInt(digitsOnly) ;

Now you can write a second constructor. Add a new constructor to the class that takes two string parameters: first, a string representing the time, (non-military style), and then a string representing the event description. This new constructor can call the mutator method you just created to do part of its work.

Request for Solution File

Ask an Expert for Answer!!
JAVA Programming: Create a new mutator called settime
Reference No:- TGS03261568

Expected delivery within 24 Hours