top of page
Time Data

 

Write a classdef for a class called timedata that includes a number of days, hours, minutes and seconds. Write the following methods for your class:
 
1. A constructor that either takes 4 arguments, one for each property, or takes one argument in seconds and converts it to days, hours, minutes and seconds.
 
2. Define methods called set.days, set.hours, set.minutes and set.seconds that take an object and a value to set each of these properties. Make sure to check that the property is within the allowable range (0- or 0-23 or 0-59) and if not return an error with the error function. By creating this set.XXX method any attempt to set these values outside the allowable range will result in an error.
 
3. Redefine (overload) the method called plus that handles addition so that you can add two timedata objects together using the standard + operator.
 
Note: Please view the embedded video in the full screen mode and choose 480p as the screen resolution to be able to read the text in the video.
bottom of page