Skip to content

farhanwk/Task_2

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Task_2

Abstract Data Type

Excercise in using ADT. Create a CLock ADT that separates between the Specification and Implementation using C++

Clock.h

  • Create a Clock ADT to store time (hour, minute, and second)
TYPE Hour 	  : integer {0..23}
TYPE Minute 	: integer {0..59}
TYPE Second 	: integer {0..59}
TYPE Clock : 
    <
    	HH	: Hour,
    	MM	: Minute,
    	SS	: Second;
    >
  • define the primitive function in Clock.h
Function IsValid(HH,MM,SS: integer) : boolean
//return true if 0≤HH≤23, and 0≤MM≤59, and 0≤MM≤59

Function MakeClock(HH, MN, SS: integer) : clock
//return clock created from input 

//Selector function
Function GetHour(c : clock) : hour
Function GetMinute(c : clock) : minute
Function GetSecond(c : clock) : second

//Value changer
Procedure SetHour(In/Out c : clock, newHH: integer)
Procedure SetMinute(In/Out c : clock, newMM: integer)
Procedure SetSecond(In/Out c : clock, newSS: integer)

//Other Operation
Function IsEqual (c1 : clock, c2  :clock) : boolean
Function AddClock (c1 : clock, c2  :clock) : clock
Procedure PrintClock ( c : clock );

Clock.cpp

  • Write the Function Implementation of Clock ADT

Main.cpp

  • Create the Driver application to try each functoin that you made

About

Abstract Data Type

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C++ 100.0%