Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Prelab Tasks : Write the declaration of the time24 class in a file named time24.h . You need to guard this file using #ifndef ,

Prelab Tasks:

  1. Write the declaration of the time24 class in a file named time24.h. You need to guard this file using #ifndef, #define, #endif. You also need to document each public member of the class.
    • Time24 -- specifies a time-of-day in hours and minutes.
    • Data members:
      • Hours (0-23)
      • Minutes (0-59)
    • Operations on the Time24 ADT:
      • constructor
      • readTime -- ask the user to enter a time-of-day in form of hours:minutes
      • writeTime(): print out the time-of-day in form of hours:minutes
      • duration( ) Measure the length of time from the current time to a time24 object passing through function and return the result as a time24 value
      • addTime -- add a specified number of minutes to a time-of-day and adjust the hours and minutes to fall in their specified range
      • getHour -- returns the hour. (accessing function)
      • getMinute -- returns the minute. (accessing function)
      • normalizeTime -- utility function sets the hour value in the range 0 to 23 and the minute value in the range 0 to 50
  2. Write the definitions of the class members in the file time24.cpp.
  3. Put your time24.h and time24.cpp in your Lab2 directory. Compile time24.cpp (just compile, don't link). Use g++ -c time24.cpp. Errors? Fix 'em. Successful compilation produces the object file time24.o

Lab Tasks

  1. Declare the isLater() function in a guarded header file named time24Aux.h. Define it in a file named time24Aux.cpp. [Don't forget to guard the time24Aux header file]
    • isLater() function that takes two time24 objects and determine whether the first time is later than the second.
      • bool isLater (const time24 & t1, const time24& t2);
  2. Write a program that declares a time24 object clock that is initially set to 9:00AM. In a loop, enter a sequence of minutes values. use each to increment time, and output the new value. Terminate the loop when clock exceeds 5:00PM, and output the final time.
    • Use the free function isLater() developed in the previous task.
    • Write your main function in a file named lab2TimeDriver.cp

    • Compile lab2TimeDriver.cpp and time24Aux.cpp. Use g++ -c time24Aux.cpp and g++ -c lab2TimeDriver.cpp At this point, you should have three object files, time24.o, time24Aux.o, and lab2TimeDriver.o

    • Link your object files to produce an executable named lab2TimeDriver.exe. Use g++ -o lab2TimeDriver.exe time24.o time24Aux.o lab2TimeDriver.o Execute your program by typing lab2TimeDriver. Compare your output with the sample output. Make sure it works correctly.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Processing Fundamentals, Design, and Implementation

Authors: David M. Kroenke, David J. Auer

14th edition

133876705, 9781292107639, 1292107634, 978-0133876703

More Books

Students also viewed these Databases questions

Question

What problems have created the client's needs?

Answered: 1 week ago