B215 Practical exercises – Week 7
ICT283 lab exercise (not assessed in this lab but must be completed)
Objectives:
· Complete and catch up with all past practical work
· To learn about issues when doing OO re-design
· Learn to use the STL vector
· Learn the Queue data structure
· Learn uses of the stack data structure
· To do testing
· Preparation for assignment 2 – Question 5 below must be completed now as it one of the requirements for assignment 2. Assessment of this question is in the assignment.
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. You would also have problems with assignment 2 if you do not complete the labs.
If you want to work on you own computer, install graphviz first, then install doxygen.
Exercise
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. Make sure you document all code using doxygen style comments.
Think about the test data you will use to demonstrate that your program works. How would you write a test plan? See Lecture notes for Topic 8. The testing needed for later units (folder “testing 4 later units”) provides examples from the final project unit that all IT students must complete. For this unit, use the material from Topic 8 lecture. The samples in “testing 4 later units” will give you an idea of what will be expected of you in third year.
1. Students (Internal) who have not demonstrated their assignment 1 to their tutor can demonstrate it this week.
2. If you have fallen behind in any of the past practical work, please catch up this week.
Convert the internal representation of your template Vector class that you had to write for your assignment 1 so that your Vector uses an STL
vector. Your vector.h will have #include
This is a “composition” relationship where your Vector encapsulates an STL vector and this was not permitted for assignment 1, but now you can use the STL vector. If you use this new Vector in your assignment 1, would your assignment 1 require code changes? Try it and see. If the assignment (application side – main program) requires changes in code, then your Vector is not done properly.
The only changes needed should be within the body of the methods of your Vector class and the private data to make use of the STL vector. There should be no change to your client code (main program and other code) which is dependent on your Vector. If there are changes to the client code, then you know that your Vector was poorly designed for the assignment. Take note of change issues that arose. You may want to discuss this with your tutor. Can you use your new Vector to store other objects? Your new Vector can be reused, so make sure you get the design right. Can your Vector be passed as references and const references to other routines and be utilised in those routines?
3. Do this exercise after you have completed all the above. Implement the calculator example shown in Lec-23 Animation.ppt. For ease of testing, read the expressions from a file which has one line per expression. If you are running short of time, do question 5 (below) first and then come back to this question (q3).
4. Examine the Queue implementation. Is anything else needed as a method? Change the sample implementation so that no STL data structure (or algorithm) is used. Class interface must not change and the QueueTest program code must not be touched but should still build and run correctly.
5. For this exercise, you will extend assignment 1 to read multiple data files. You will need to be able to read multiple data files for assignment 2, so the multiple-file reading problem needs to be solved now. Run assignment 1 with multiple files being used to address the menu options. The files you need are already in the data folder.
Use the following approach:
a. Use data files for at least 3 different years. Keep all 3 files in a sub-directory called data. You do not need to download any more data as sufficient sample data has been provided in the data folder. If you do want to download, be careful as the columns may have changed.
b. Copy the file names of the CSV data files into a text file called met_index.txt. The met_index.txt is also found in the data sub-directory. A sample met_index.txt file is found in the data folder. You need to test and add more files to it. Your program will first open data/met_index.txt, read each CSV data file name from met_index.txt and load the contents of the CSV data file into your assignment 1. You must not assume that the CSV data files are listed in any sort order in met_index.txt. A very high level algorithm is:
———————————————————————————————————
Open data/met_index.txt
For each CSV file listed in data/met_index.txt
Open the CSV file and read the data into the data structure you used for assignment 1
Close the CSV data file once reading is complete
Endfor
Display Menu
———————————————————————————————————
The program reads all files and loads the appropriate data structures before the menu is displayed to the end user.
Menu options should now be usable for a number of different years.
Add more data files to data and met_index.txt and test your Assignment 1. You must do this now before the data structure changes are incorporated into the assignment.
Note:
· You should test your program in question 5 using more data files. Question 5 and Assignment 2 needs to work with multiple data files at a time. You do not need to download any more data as sufficient sample data has been provided. If you do want to download, be careful as the columns may have changed. Download from http://wwwmet.murdoch.edu.au/ if you want to. When downloading, use the data group on the left, don’t tick UTC date/time, and select the required columns of data at the web site. You will get a .csv file that will have the sensor legend at the top. Columns may be different in the new data files compared to the sample data as the wwwmet web site may have been updated. If the columns are in a different order, you read routine would not work properly.
· Open the csv file in Microsoft Excel and delete the top few rows but keep the header row. Check that the data/time format is correct in Excel, and then save the file as a .csv file in the data directory for this lab. If the date is not in the dd/mm/yyyy format, use Excel’s help to find out how to change the date format, and then save as indicated earlier. Check that the time values are sensible. You do this by checking that there should not be large values of solar radiation recorded when it is supposed to be dark (no sun) in Perth. If you see large values recorded when it is dark, the time is not WA time (WAST) but is UTC (like GMT – 8 hours behind). Also check that the columns are in the correct order to that used in assignment 1. Open the csv file in notepad++ (https://notepad-plus-plus.org/) to examine what your program will see when reading in the file.
· You need to complete question 5 now. If you start having problems with assignment 2, we may ask you to demonstrate completion of all labs that are marked as preparation for assignment 2. Detailed testing would need to be demonstrated for the labs.
� If you actually used the STL vector in assignment 1, then you have violated the assignment requirements. Next time read the specifications more carefully. You should also pay attention to the question and answer file.
PAGE
1
LabExcWk08.doc