Lez's home   MSc Degree   -   Previous page   Next page  

Critical Appraisal

Introduction

The main purpose of this assignment was to write the declaration and implementation files in order to run the two supplied driving .cpp files of testdial.cpp and testclk.cpp. This involved writing the classes Dial and Clock24. Further implementations of using the class Dial were required. Two new classes (Imperial and Meter) were created and are documented below.[1]

testdial.cpp

This is a supplied program to run dial.cpp and dial.h. The source code for testdial.cpp is on page 11. dial.cpp is on page 15 and dial.h is on page 14. Reading through the testdial.cpp code showed which constructors and functions were required for class Dial. These were:

testclk.cpp

This is a supplied program to run clock24.cpp and clock24.h. Note: clock24.h #includes dial.h so the functions described above are available to it. The source code for testclk.cpp is on page 12. clock24.cpp is on page 17 and clock24.h is on page 16. The constructors and functions required for class Clock24 are as follows:

If an operator* function had been supplied for class Dial, it would have been possible for the overloaded operator- in class Clock24 to have used Dials for the calculation rather than referring directly to the value. This was not implemented due to lack of time.

metric.cpp

This is the driving .cpp file for the convert.exe program. It allows users to add measurements in feet and inches and obtain a result in yards, feet and inches, which is then converted to metres. Error checking on input data is included. This implementation makes use of class Imperial in imprl.cpp and imprl.h.

worm.cpp

This is the driving file for inchworm.exe, which uses class Imperial (in imprl.cpp and imprl.h). This program allows a user to set the starting position of a worm (within a length of 12 inches), specify how fast it can go (in inches per hour) and for how long it can travel. Limits have been included for speed (50 inches per hour) and time of travel (24 hours). This is a simple once-only program.

imprl.cpp & imprl.h

imprl.h is the header file for imprl.cpp and #include’s dial.h. Class Imperial has private data members of three Dials (for yards, feet and inches), and the following:

Two more functions of operator- and operator+ are included, but these are not used in the implementations of worm.cpp or metric.cpp. They may be required for future implementations of class Imperial, so have not been removed.

elecmetr.cpp

This is the driving file for the elecmetr.exe program. This program allows the user to input the current meter reading, the number of units used per day and the number of days to run. The output displays the final meter reading, the number of units used and the total cost. The cost_per_unit is set within the program and fixed at compilation. This could be changed to an input value, allowing the user to see the same number of units used with differing unit cost. elecmetr.cpp implementation makes use of class Meter (which #include’s dial.h).

meter.cpp & meter.h

meter.h is the header file for meter.cpp. Class Meter has private data members of four Dials (thou, hund, ten and unit). Since all these Dials will have the same dial divisions, it would be possible to declare them as an array. This was not done due to lack of time. The public members of class Meter are as follows:

Future Improvements

Possible future improvements which could be made to these programs:

class Dial & class Clock24

convert.exe

inchworm.exe

elecmetr.exe


FOOTNOTES:

  1. Class names will be shown with an initial capital (e.g. Dial, Clock24), variables, functions, etc will be shown in courier type face (e.g. dialdivision), and file names will be shown in italics (e.g. testdial.cpp).

 


Lez's home   MSc Degree   -   Previous page   Next page  
Copyright 2000 Lez Bullwer