Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Hw otwen-oriented Programmingin MATUN Watch The Problem with T me Define a dass

ID: 3865060 • Letter: H

Question

Hw otwen-oriented Programmingin MATUN Watch The Problem with T me Define a dass in MATLAB that represents adock ll 12 l 7 6 3 How IComoatbaty Model AaBbC Your Cock class should have the following methods (with these EDACT names and all properties required to support these methods: (green highlighted methods are optional challenges) Method Description clock with initial time oooooo GnT January 1970 Adds the even integernumberorday Houn Adds the Even integer number of hours to the clock. Adds the even integer number ofmirutes the than equal to or yeater than the even time countdown Returns the time until the given time represented a Cock object is reached as a string in the format lla value is arra, do not indude that line draw Drawn the clock as aGaphicalfigure. the day on the clock eek Returns the day or the week forthe

Explanation / Answer

Please find the Matlab Code below.

CODE:
classdef Clock
% Class which represents Clock.

properties
% properties of the class
minute = 0;
hour;
day;
month;
year;
end
methods
% methods, including the constructor are defined in this block
function obj = Clock(minute,hour,day,month,year)
% class constructor
if(nargin > 0)
obj.minute = minute;
obj.hour = hour;
obj.day = day;
obj.month = month;
obj.year = year;
end
end
function obj = addDays(obj,numdays)
obj.day = obj.day + numdays;
end
       function obj = addHours(obj,numHours)
obj.day = obj.hour + numHours;
end
       function obj = addMinutes(obj,numMinutes)
obj.day = obj.minute + numMinutes;
end
       function obj = getMonth(obj)
           obj.month = obj.month
       end
       function notatn = getNotation(obj)
       if(obj.hour > 12)
               notatn = 24
           else
               notatn = 12
           end
       end
       function res = isLeapYear(obj)
       if (mod(obj.year,4) == 0 && mod(obj.year,100) ==0 && mod(obj.year, 400) == 0)
           res = true
           else
           res = false
           end
       end
end
end

I have implemented few methods. On similar lines other methods can be implemented.

OUTPUT:
Create an instance of Clock.

>> d1 = Clock(0,3,27,2,1998)

d1 =

Clock

Properties:
minute: 0
hour: 3
day: 27
month: 2
year: 1998

Methods

Add 3 more days using the method. In the output you can see the number
of days has increased to 30 from 27.

>> d1 = d1.addDays(3)

d1 =

Clock

Properties:
minute: 0
hour: 3
day: 30
month: 2
year: 1998

>> a = d1.isLeapYear()

res =

0


a =

0

Similarly try executing other methods, it will work.

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Chat Now And Get Quote