B215 Practical exercises – Week 7
ICT283 (not assessed but should be attempted)
Objectives:
To learn
· How to read C++ code
· Do code maintenance
· Do testing
It is very important not to fall behind with these exercises.
You should note that even though an exercise is not assessed, not attempting the exercise would make it very difficult for you to understand subsequent material.
If you want to work on you own computer, install Graphviz first, then install Doxygen.
Exercise
To do this lab, you must have completed all previous work.
If you have skipped any exercise in any of the previous labs, please go back and complete.
Do not start coding until you have worked out exactly what is required. Do this on paper. Draw a UML diagram illustrating how the classes are connected and being used. You need to read all the sub exercises (sub tasks) below first to work out what is needed and then plan the best way to tackle each of the sub tasks listed. You may need to read the specifications more than once to understand what is really needed. Make sure you document all code using doxygen style comments. For the purpose of this exercise use underscores to join long names together so that they are actually one string.
Think about the test data you will use to demonstrate that your program works. You can assume that the input data file contains data in the correct format. This means that you must create the data file correctly.
For this lab, C style strings are used. See the textbook chapter on Arrays and Strings (sub-section C-Strings). C-strings are arrays of char. The end of the string is marked by a null character. C-strings routines are fast as they are not object-oriented. But such strings need to be handled carefully as there is no protection if you exceed array bounds. You may want to take a look at this site http://www.cplusplus.com/. The library reference http://www.cplusplus.com/reference/ shows what is available in the C library. See cstring (string.h). You will find an explanation of each of the C-string routine along with an example showing to use of the routine. Lect-08.ppt in Topic03 also has some brief descriptions.
Do not use the object-oriented string (std::string) for this exercise. We will use these later.
1. Use Registration.zip from the previous exercise. Rename the Course class to Unit as it will be used to represent a unit at Murdoch. Modify the class so that it has unit name, unit id and credits. Section name is not used. The output operators use the new attributes to display. Provide appropriate set and get methods for the class.
Create a data file with unit information relevant to Murdoch units. Modify the main program so that the new data file is used with the correct unit information. Test your program to make sure it works as before.
2. Create a new class call Result. Result will contain unit and the marks (one floating point number) obtained for that unit. Provide appropriate set and get methods for the class. Think about how the class will be used. The registration class will be modified to have a list of Results instead of a list of Courses.
Modify the data file to cater for marks. The output operator for Result should output the unit information and the marks. The output for registration in the output data file will contain the Student ID, Semester, unit information and marks for each unit. The output should be in a similar format as the output in the previous exercise except it will have more relevant information. A sample run is given below.
3. Run doxygen and examine the output to see that your initial design (using staruml) matches the design as shown in doxygen.
Sample Run:
Student ID: 12345678
Semester: 1
Unit ID: ICT283
Unit Name: Data_Structures_And_Abstractions
Credits: 3
Marks: 90
Unit ID: ICT289
Unit Name: Computer_Graphics
Credits: 3
Marks: 97
Number of Units = 2
Total Credits = 6
FILENAME
LabExcSession03.doc