Create a Class Called Mytime That Has the Following Attributes

Create a Class Called Mytime That Has the Following Attributes

<p> Lab Set Q1W5 Classes & Objects</p><p>Level 1</p><p>Create a class called MyTime that has the following attributes:</p><p>Variables:  minutes – stores the minute as an integer  seconds – stores the seconds as a real number Methods: 1. MyTime (constructor) o Input Variables – integer minute, double second o Output – none o Action – takes in and sets the initial variable values 2. getMinute o Input Variables – none o Output – integer o Action – returns the minute 3. getSecond o Input Variables – none o Output – double o Action – returns the seconds 4. toString o Input Variables – none o Output – String o Action – returns a String description of the time such that the following variable values would result in the following String being returned: minute – 32, seconds – 24.35 “32 : 24.35” Level 2</p><p>Create a class called MyTime that has the following attributes:</p><p>Variables:  hours – stores the hour as an integer  minutes – stores the minute as an integer  seconds – stores the seconds as a real number Methods: 1. MyTime (constructor) o Input Variables – integer hour, integer minute, double second o Output – none o Action – takes in and sets the initial variable values 2. getHour o Input Variables – none o Output – integer o Action – returns the hour 3. getMinute o Input Variables – none o Output – integer o Action – returns the minute 4. getSecond o Input Variables – none o Output – double o Action – returns the seconds 5. toString o Input Variables – none o Output – String o Action – returns a String description of the time such that the following variable values would result in the following String being returned: hour – 17, minute – 32, seconds – 24.35 “5 PM : 32 : 24.35” 6. equals o Input Variables – Time other o Output – boolean o Action – returns whether or not the time object passed in has the same time as this time object Level 3</p><p>Create a class called MyTime that has the following attributes:</p><p>Variables:  hours – stores the hour as an integer  minutes – stores the minute as an integer  seconds – stores the seconds as a real number Methods: 7. MyTime (constructor) o Input Variables – integer hour, integer minute, double second o Output – none o Action – takes in and sets the initial variable values 8. getHour o Input Variables – none o Output – integer o Action – returns the hour 9. getMinute o Input Variables – none o Output – integer o Action – returns the minute 10. getSecond o Input Variables – none o Output – double o Action – returns the seconds 11. toString o Input Variables – none o Output – String o Action – returns a String description of the time such that the following variable values would result in the following String being returned: hour – 17, minute – 32, seconds – 24.35 “5 PM : 32 : 24.35” 12. equals o Input Variables – MyTime other o Output – boolean o Action – returns whether or not the time object passed in has the same time as this time object 13. compareTo o Input Variables – MyTime other o Output – integer o Action – Compares this object with the specified object for order. Returns a negative integer if the other time comes after this one, zero if they are the same, or a positive integer if this one comes after the other one. Level 4</p><p>Create a class called MyTime that has the following attributes:</p><p>Variables:  year – stores the year as an integer  month – stores the month as an integer  day – stores the day as an integer  hours – stores the hour as an integer  minutes – stores the minute as an integer  seconds – stores the seconds as a real number Methods: 1. MyTime (constructor) o Input Variables – integer year, integer month, integer day, integer hour, integer minute, double second o Output – none o Action – takes in and sets the initial variable values 2. getYear o Input Variables – none o Output – integer o Action – returns the year 3. getMonth o Input Variables – none o Output – integer o Action – returns the month 4. getDay o Input Variables – none o Output – integer o Action – returns the day 5. getHour o Input Variables – none o Output – integer o Action – returns the hour 6. getMinute o Input Variables – none o Output – integer o Action – returns the minute 7. getSecond o Input Variables – none o Output – double o Action – returns the seconds 8. toString o Input Variables – none o Output – String o Action – returns a String description of the time such that the following variable values would result in the following String being returned: year – 2014, month – 10, hour – 17, minute – 32, seconds – 24.35 “2014 : October 2 : 5 PM : 32 : 24.35” 9. equals o Input Variables – MyTime other o Output – boolean o Action –returns whether or not the time object passed in has the same time as this time object 10. compareTo o Input Variables – MyTime other o Output – integer o Action – Compares this object with the specified object for order. Returns a negative integer if the other time comes after this one, zero if they are the same, or a positive integer if this one comes after the other one. Level 5</p><p>Create a class called MyTime that has the following attributes:</p><p>Variables:  year – stores the year as an integer  month – stores the month as an integer  day – stores the day as an integer  hours – stores the hour as an integer  minutes – stores the minute as an integer  seconds – stores the seconds as a real number Methods: 1. MyTime (constructor) o Input Variables – integer year, integer month, integer day, integer hour, integer minute, double second o Output – none o Action – takes in and sets the initial variable values 2. getYear o Input Variables – none o Output – integer o Action – returns the year 3. getMonth o Input Variables – none o Output – integer o Action – returns the month 4. getDay o Input Variables – none o Output – integer o Action – returns the day 5. getHour o Input Variables – none o Output – integer o Action – returns the hour 6. getMinute o Input Variables – none o Output – integer o Action – returns the minute 7. getSecond o Input Variables – none o Output – double o Action – returns the seconds 8. toString o Input Variables – none o Output – String o Action – returns a String description of the time such that the following variable values would result in the following String being returned: year – 2014, month – 10, hour – 17, minute – 32, seconds – 24.35 “2014 : October 2 : 5 PM : 32 : 24.35” 9. equals o Input Variables – MyTime other o Output – boolean o Action –returns whether or not the time object passed in has the same time as this time object 10. compareTo o Input Variables – MyTime other o Output – integer o Action – Compares this object with the specified object for order. Returns a negative integer if the other time comes after this one, zero if they are the same, or a positive integer if this one comes after the other one. 11. incrementMinute o Input Variables – none o Output – none o Action – Increments the time stored by one minute. This method takes into account how minutes eventually increment hours, days, months, and years once each one reaches their respective limit.</p>

View Full Text

Details

  • File Type
    pdf
  • Upload Time
    -
  • Content Languages
    English
  • Upload User
    Anonymous/Not logged-in
  • File Pages
    7 Page
  • File Size
    -

Download

Channel Download Status
Express Download Enable

Copyright

We respect the copyrights and intellectual property rights of all users. All uploaded documents are either original works of the uploader or authorized works of the rightful owners.

  • Not to be reproduced or distributed without explicit permission.
  • Not used for commercial purposes outside of approved use cases.
  • Not used to infringe on the rights of the original creators.
  • If you believe any content infringes your copyright, please contact us immediately.

Support

For help with questions, suggestions, or problems, please contact us