Find Us On: Facebook Twitter Rss Feed Blog
Need To Register? Sign Up Login

C++: Time of day project: Example attached below

DBprogrammer
DBprogrammer 


Create two classes to handle time of day and a program to test these classes 1) The main (parent) class must be able to: A. Accept times in either AM/PM form or 24 clock form (no AM/PM) i. 11:55 AM ii. 13:55:43 iii. etc. B. Add hours, minutes, and seconds to a time C. Take the difference between two times as a time object D. Display times in formats shown in A above or any others that you think are interesting. 2) The child class should take times in 24 hour form (1355) and also, by default, display times in this form. 3) The classes should include (only include those items in the child class that perform differently from the same items in the parent class): A. Constructor(s) B. Set Functions C. Get Functions D. Overloaded Operators for: i. Adding minutes to time ii. Taking differences between two times iii. Assigning a value to a time iv. Casting a time to a string E. Overloaded ostream << and istream >> (see my DateClass code) F. Additional functions as required i. AddHours ii. AddSeconds iii. etc. 4) The test program should demonstrate most (if not all) of these capabilities. 5) You should submit 5 files (you can compress these into one ZIP file and submit that file): A. Two Header files (.h), one for each class. B. Two Code files (.cpp), one for each class C. Test File (includes main and is a .cpp) The assignment also contains a word document containing the code for a DateClass with a child class of Eurodate that I created. These classes contain equivalent functionality for you to review and use as a template (if you wish). If you have any questions, please email them to me. Please note that though you need both classes to get an A, submitting a complete parent class could get you a B. If the program does not compile, that is an immediate 20 point deduction. Please make sure that you comment your code extensively (see my example). I will take off points for lack of comments, poor indentation, and other style issues. Attachments Tags Clarifications

Answers

Time Project C++

SW_wizard
SW_wizard 



All 5 files are present in the zip file Attachments
TimeProject.zip (4 K) Download


Preview
operator: t4 =\"11:22:11\" ==>" ; t4.display(); //Test child class cout << endl << "Now testing child class: SpecialTime" << endl; SpecialTime st1(9,10,0); cout << "SpecialTime1(9,10,0) = "; st1.display(); SpecialTime st2; st2.setTime("11:44"); cout << "SpecialTime2 as string (\"11:44\") = ";

Preview
token = asTime.substr(0,asTime.find_first_of(":")); asTime = asTime.substr(asTime.find_first_of(":") + 1); //printf("%s ",token.c_str()); arr[i] = atoi(token.c_str()); i++; } TimeClass::setTime(arr[0], arr[1],0); //second value is 0 for SpecialTime return true; } bool SpecialTime::setTime(int hr, int min, int sec){ TimeClass::setTime(hr,min,0); //call method of parent

Preview
hr, min, sec; string str; getTime(hr, min, sec, str); ss << hr << ":" << min <<":"<<second << " " << str; //format is "2:29:11 PM" } return ss.str(); //return the string } bool TimeClass::addHours(int hr){ //add hours to the calling object

Screenshots
Purchase Answer