CST1801 Visual
Basic I
Lab Week 12
Exercises |
Exercise RationalWrite
(20 points)
In this exercise your are going to build upon the Rational exercise that you completed in a previous week.
Do not use any pathing in the file names. This is to ensure that the files are written in the same directory as the executable. Hint: For reference, here is the object serialization example we did in class. Trek.vb and Trek.exe. Remember to mark classes serializable with the <serializable> attribute. Here is a link about basic serialization from the MSDN documentation. Result (These programs read and write files. You MUST save to your local machine and run in order for these programs to execute correctly.) Sample
rationalresult.txt file generated by the program. |
Exercise TriAreaIni
(10 points)
In this exercise you are going to build upon the Triangle Area exercise (Exercise 17.3) that your did in a previous week. Below was the original exercise: If you know the length of the three sides of a triangle, the area can be calculated by:
where
Write method for calculating and returning the area. Make it throw a suitable exception (with a message) when the three lengths cannot form a triangle. Catch input formatting errors in the main program. Modify the program so that it uses the Ini class that was demonstrated in class. The name of ini file shall be "triarea.ini". Use pathing in the file name so that the file is written to the C:\Temp directory. If pathing was not used, the file would get written to the Windows directory. Write to the ini file the last 3 sides used (a, b, c) and the area result. When the program is restarted, the last 3 sides used should be reloaded. Hint: For reference here is Ini.vb and IniTest.vb files and the IniTest.exe executable that was demonstrated in class. Result (These programs read and write files. You MUST save to your local machine and run in order for these programs to execute correctly.) Sample
triarea.ini
file generated by the program. |