/* CSC15 Lab 8 For this lab you will write a class that will form the computational part of a program that displays a countdown timer. The most important function of the class will involve a nested loop that decrements the timer appropriately. 0. download this file (timer.C) and the graphical component (timergui.C) from the class homepage. 1. do "moc timergui.C -o timergui.moc" (only once) 2. Using the following code as template, define the class. PLEASE NOTE that this class is NOT the same as the time class we studied before. Instead of minutes and seconds, this class needs to have 4 variables (m1,m0,s1,s0) because the graphical display shows the time using four separately managed digits. The minute value will consist of digits m1 and m0, with m1 ranging from 0 to 5 and m0 ranging from 0 to 9, and similarly for s1 and s0. Additional instructions in comments below. 3. Two functions, displayUpdate(int m1, int m0, int s1, int s0) and delay(int approx_millesconds) have been predefined. The first one updates the graphical display with the parameters passed to it. The second one delays by a number of milliseconds. The exact time is approximate, so you'll NEED TO adjust it so that your timer synchronizes with real time. (i.e., it should really work). Example: displayUpdate(3,4,3,0); will display 34 minutes and 30 seconds delay(1000); will delay NOT EXACTLY 1000 milliseconds. Hand in: paper sketch of start function printout of your code. Check the class web page in case I come up with improvements to the GUI. */ /* template: no extra #include's needed */ // the next 2 lines are 'prototypes': promises that functions will be defined // later (in timergui.C). Ignore for now void displayUpdate(int,int,int,int); // ignore void delay(int); // ignore class timer { private: // declare integer variables m1, m0, s1, s0 as explained above // declare a boolean variable called running public: // define a constructor that intializes m1,m0,s1,s0 with parameters // The constructor should check that the values are appropriate // (i.e, if s1 is >=6, set it to be the max possible value - 5) // The constructor should also intialize running to false. // define a method called "reset" that sets running to false, waits // for 100 milliseconds using the delay function, and call displayUpdate // before exiting. Does this function need any parameters? return any // values? Don't know? Ask. // define a "start" function. This function will be the principal // portion of the assignment. It should count down from the values // the user typed in towards zero using a nested loops (4 levels). // In the body of the innermost loop, you need to call displayUpdate and // delay after updating the appropriate (s0) value. // Before starting the loop, set running to true. At the end of // everything, set running to false. Your while loops should all terminate // if running ever gets changed to false in the middle. }; // end class timer // don't touch the line below!!!!!! #include "timergui.C"