Package components.ampmclock
Interface AMPMClock
AMPMClock number component with primary methods.
- Mathematical Subtypes:
HOUR_MODEL is integer exemplar h constraint 1 <= h <= 12 MINUTE_SECOND_MODEL is integer exemplar m constraint 0 <= m <= 59 AM_PM_CLOCK_MODEL is ( hours: HOUR_MODEL minutes: MINUTE_SECOND_MODEL seconds: MINUTE_SECOND_MODEL am: boolean )- Mathematical Model (abstract value and abstract invariant of this):
type AMPMClock is modeled by AM_PM_CLOCK_MODEL- Constructor(s) (initial abstract value(s) of this):
(): ensures this.hours = 12 and this.minutes = 0 and this.seconds = 0 and this.am = true (int h, int m, int s, boolean a): requires 1 <= h <= 12 and 0 <= m <= 59 and 0 <= s <= 59 ensures this.hours = h and this.minutes = m and this.seconds = s and this.am = a
-
Method Summary
Modifier and TypeMethodDescriptioninthours()Reportsthis.hours.booleanisAM()Reportsthis.am.intminutes()Reportsthis.minutes.intseconds()Reportsthis.seconds.voidsetAM(boolean am) Setsthis.amtoam.voidsetHours(int newHours) Setsthis.hourstonewHours.voidsetMinutes(int newMinutes) Setsthis.minutestonewMinutes.voidsetSeconds(int newSeconds) Setsthis.secondstonewSeconds.Methods inherited from interface components.standard.Standard
clear, newInstance, transferFrom
-
Method Details
-
setHours
Setsthis.hourstonewHours.- Parameters:
newHours- the new hours forthis- Replaces:
this.hours- Requires:
1 <= newHours <= 12- Ensures:
this.hours = newHours
-
setMinutes
Setsthis.minutestonewMinutes.- Parameters:
newMinutes- the new minutes forthis- Replaces:
this.minutes- Requires:
0 <= newMinutes <= 59- Ensures:
this.minutes = newMinutes
-
setSeconds
Setsthis.secondstonewSeconds.- Parameters:
newSeconds- the new seconds forthis- Replaces:
this.seconds- Requires:
0 <= newSeconds <= 59- Ensures:
this.seconds = newSeconds
-
setAM
Setsthis.amtoam.- Parameters:
am- the new am forthis- Replaces:
this.am- Ensures:
this.am = am
-
hours
int hours()Reportsthis.hours.- Returns:
this.hours- Ensures:
hours = this.hours
-
minutes
int minutes()Reportsthis.minutes.- Returns:
this.minutes- Ensures:
minutes = this.minutes
-
seconds
int seconds()Reportsthis.seconds.- Returns:
this.seconds- Ensures:
seconds = this.seconds
-
isAM
boolean isAM()Reportsthis.am.- Returns:
this.am- Ensures:
isAM = this.am
-