Public paste
bs
By: bs | Date: Oct 2 2007 02:31 | Format: None | Expires: never | Size: 2.56 KB | Hits: 756

  1. For this project you are to specify and implement a derived class extclockType from class clockType. The latter is available from the Chapter 01 Source Code/ClockType folder that you get when you install the textbook examples.
  2.  
  3.         You must derive extclockType as public and you will need to make just one single change to clockType so that the member functions of the former can directly access the data members of the latter. The derived class will have a data member for storing the time zone.
  4.  
  5.         A description of the components of the extclockType class follows below.
  6.  
  7. Holds the time zone as a two-letter word (CT, PT, ET, MT).
  8.  
  9. Overloaded operator<<: sends to the standard output device a time in the format HH:MM:SS TZ, where HH is the hour, MM is the minute, SS is the second, and TZ is the time zone. Time zone must be shown in capital letters.
  10. Overloaded operator>>: reads from the standard input device a time entered by the user as HH:MM:SS TZ, where HH is the hour, MM is the minute, SS is the second, and TZ is the time zone. Note: the user may enter the time zone in upper or lower case but it must be saved in upper case.
  11. Overloaded operator++ (prefix form): increments the time by one second and returns this value.
  12. Overloaded operator++ (postfix form): increments the time by one second but returns the previous value (before the increment).
  13. Overloaded operator==: compares two times based on their hours, minutes, seconds, and time zone. Returns true if all four components for the two times  match, false otherwise.
  14. Overloaded operator+: adds two times and returns the resulting time. If the time zone of the two times is not the same, it prints the message “The time zones are different; the times cannot be added!” and returns 0:0:0 NT (No Time)  as the result.
  15. Parameterized constructor: explicitly invokes the parameterized constructor of class clockType to initialize hours, minutes, and seconds to the values passed by the user and then initializes the time zone data member with the value passed by the user.
  16. Default constructor: invokes the default constructor of class clockType to initialize hours, minutes, and seconds and then initializes the time zone data member to "CT".
  17.  
  18.  
  19.         Since the textbook does not show how to overload the increment operator you will have to get this information from the slides available from Blackboard, other books, the Web, etc. Below are the prototypes of these two operators for your reference.
  20.  
  21.         extclockType operator++();      //Overload the operator ++ (prefix form)
  22.  
  23.         extclockType operator++(int); //Overload the operator ++ (postfix form)