Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Description of class members Fields: There are no fields for this class. Properties: TIME _ FORMAT this class variable is of type TimeFormat and it
Description of class members
Fields:
There are no fields for this class.
Properties:
TIMEFORMAT this class variable is of type
TimeFormat and it represents the intended
format of the ToString method. This
field has private accessibility and it initializes
to TimeFormat.Hour at declaration.
A class member that is decorated with the
static keyword implies that only one
copy of this member exists and it is shared
by all objects of the class. ie If it is changed
then all object will see the new value
immediately.
A class method can only access other class
member fieldspropertiesmethods
UML Class Diagram
$ static
private
public
# protected
Programming II Time: enum, class variable WeekLab
Winter Page of
Hour this is an integer representing the hour value this object. This property has public read
access and the setter is missing.
Minute this is an integer representing the minute value this object. This property has public
read access and the setter is missing.
Constructor:
public Timeint hours int minutes This is a public constructor that takes
two integer arguments with default values of If checks if the first argument is between and
it assigns it to the Hour property otherwise a value of is assign to the hour property. Similarly
the second argument is check if it is between and then it is assigned to the Minute property
otherwise a value of is assigned to the Minute property.
Methods:
public override string ToString This public method overrides the ToString of the
object class. It does not take any argument and returns a string representation of the object. The
return value will depend on the field TIMEFORMAT value of the class. So it is a good plan if you
use a switch statement to handle the three possibilities. Your switch statement should check the
value of the TIMEFORMAT field.
If you have a Time object with the hours value as and the minutes value as then the print out
of the object will be
if TIMEFORMAT is set to TimeFormat.MIL. Use
the d format specifier to get the leading zero.
: if TIMEFORMAT is set to TimeFormat.HOUR
Again, use the d format specifier to get the leading zero.
: PM if TIMEFORMAT is set to TimeFormat.HOUR Again, use the d format specifier
to get the leading zero.
public static void SetTimeFormatTimeFormat timeformat This a class method
that is public. It takes a single TimeFormat argument and
assigns it to the static TIMEFORMAT field.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started