Week 14 - Getting there
| C++ Study w/e 24 Feb 2008 | |
| Week #: |
14
|
| Week Hours: |
16.2
|
| Total Hours: |
157.6
|
Study wise, a very productive week, 16 hours spread over 5 days. When I say 16 hours I mean 16 hours. I use a stop-watch program to keep track of the hours and religiously stop it when taking breaks. At the end of this process (studying from the book) it'll be interesting, well for me at least, knowing how much time, both in hours and weeks, were spent in order to attain a certain level. This particular figure will be a yardstick for further C++ study (I'm thinking in terms of GUI programming).
Continued with Chapter 11, the programming exercises, completing them and the chapter on Thursday. The programming exercises were relatively straight forward.
Back in week 5 I wrote a program, which was not a part of the book, merely to test my knowledge at that point in time. That program, being a simple single source code file, accepted user input of distance and time (broken down into component time parts), calculated the pace (mins/km) and displayed it.
I revisted that program and completely re-wrote it, this time incorporating Class and Objects and the inclusion of multiple source code files (headers and .cpp's).
- Each run (distance & time - duration) is an object of the Class Run
- Each object now accounts for a user defined distance units (km or miles)
- The class handles all user input, calculations and output
- Created a functions.h and functions.cpp file which holds the function necessary to clear the input buffer. This sequence of code used in numerous places throughout the program, therefore an ideal candidate to form a function
- Fixed output display whereby previously for seconds, if less than 10 seconds, only one digit was displayed ie 5:2 (5 mins 2 secs) should be 5:02.
- Regardless of the user inputted distance units, displayed also is the opposite version, so if kilometres is selected, mins/km is displayed and then mins/mile displayed. This was an afterthought, but it highlighted how easy programming with objects and classes really is. It only took a few addition lines of code to achieve it. I was using what I had already written. At this point the light globe lit up.
The program is nothing earth shattering, it was simply done to cement my learning to date. I believe this is the process where learning actually takes place.
I know in time I'll look back on this code and probably cringe, as I did viewing my program written back in week 5.
Briefly touched on Chapter 12, Classes and Dynamic Memory Allocation, and that's where I'll continue from next week.
- Steve's blog
- Login or register to post comments
- 183 reads


Recent comments
1 hour 49 min ago
1 day 1 hour ago
1 day 7 hours ago
1 day 17 hours ago
1 day 18 hours ago
3 weeks 6 days ago
3 weeks 6 days ago
4 weeks 2 hours ago
10 weeks 1 day ago
11 weeks 4 days ago