next up previous
Up: Return

Final Program

Group: Captain: Recorder: Reflector:

Motivation

An important objective is to learn the skills that will allow you to learn more about C++ (or any other programming language, even ones not yet devised!) on your own. "Life-long learner" sums it up.

Learning to learn is essential to make you into an engineer who can stay up-to-date throughout your long carreer.

Objectives

1.
Learn to learn.
2.
Improve program neatness.
3.
Strengthen previous knowledge.

Performance Criteria

1.
Your success in converting the part object of your program into an array of such objects. Your success in modifying your program so that you can enter all your parts of your Sterling engine into the entries of this array. Your success in printing out a list of the entered Stirling engine parts when the program exits and E-mailing the list and program to the instructor. (50%)

Hint: Start with a small number of parts, say the sockethead cap screw, (all steel, no brass), flywheel (all brass, no steel), and displacer cylinder (all steel.)

Hint: You will need an index for your array of part objects. You may want to call that index part_index. Initialize part_index to -1. Then each time the user selects 'P' to add a new part, increment part_index by one.

Hint: After the while, you will want to use a variable, say number_of_parts, to hold the total number of parts that the user has defined.

2.
Make at least two significant improvements (of your own choice) to the program. You can do whatever you want. But neatness improvements do not count. (Neatness in counted separately, see below.) (Each 10%).

3.
The neatness, clarity, and simplicity of your final programs. (30%).

Resources

1.
Your creativity.
2.
Your knowledge of C++.
3.
The course web page.
4.
The textbook.
5.
The instructor.
6.
The TA.
7.
The online help facilities of Windows, Netscape or Internet Explorer, and the C++ compiler.

Plan

1.
Do the first program. Test throroughly and check for neatness. Mail program and produced parts table to the instructor.
2.
Brainstorm with your group what can be improved in your program. Make the improvements. Mail to the instructor.

Exercises

1.
Change the program so that the parts can include aluminum. There are various ways of doing this, from simply copying and changing the brass or steel code to defining a materials cost object and creating three instances of that.

2.
Change the program so that it includes an inventory (how much is in stock) of each part.

3.
Print out all costs in dollars and cents, in the form $ddd.cc. Test with $1.00, $1.2345 (to print as $1.23), $10.00, $12.3456, and $0.0345. Hint: Use the I/O manipulator setiosflags(ios::fixed) to set non-scientific notation. This one is used the same way as other I/O manipulators that are discussed in the book. It is turned off by resetiosflags(ios::fixed).

4.
Modify the part class so that it includes the manufacturing cost.

5.
Expand your menu to allow the user to change the cost of the materials.

6.
Expand your menu to allow the user to correct mistakes in entering part data.

7.
Expand your menu to allow the user to delete incorrectly entered part data.

8.
Expand your menu to allow the user to print out the parts defined so far.

9.
Create an error message function error_msg so that, for example, error_msg("Any text", 5) will print out the message between the quotes, ring the bell, wait 5 seconds, and go to the next line. Use this function to handle all your error messages. Make the value 3 the default if the second argument is omitted. Hints: Use sleep(i) to wait i seconds. On Unix, you can find this function in unistd.h, under DOS it should be in dos.h. Otherwise use:
   #include <time.h>
   void sleep(int i)
      {time_t start; start=time(NULL); while (time(NULL)-start<i);}

10.
Add a menu option `U' that allows the user to either use kg or lb as unit of weight. In the menu header, print out whether we are using lb or kg, When the user chooses option U, the program will switch from kg units to lb units, or back. But internally, store all values in kg units.

11.
Change the program so that it asks the user ``Do you really want to quit? [Y/N]: '' and allows the user to enter a `Y' or an `N' to quit or continue. It should keep prompting until the user enters Y or N. Make sure the program is case-insensitive. Hints: Ask yourself: what sort of construct can keep asking for Y or N until the user enters one of the two? How can you abort the quitting process?

12.
Change your program so that it only uses storage for parts that are actually used. So instead of creating, say, 100 parts using part_object part_array[100], only create a part when the user requests it by means of the ``P'' menu choice. Hints: You can do this by instead creating 100 pointers to parts using, say part_object *part_pointer_array[100]. (The star ensures that you create pointers to parts instead of actual parts, see the lesson ``Understanding Pointers''.) Then when the user is defining a new part with the ``P'' menu choice, you can create the actual storage for that part with the part_pointer_array[...] = new part_object; statement. Note that you will have to use the arrow notation instead of the dot notation, for example, you must use part_pointer_array[...]->display(...) instead of part_pointer_array[...].display(...).

13.
Whenever the user is to enter the cost of a material, show him the current value, and allow him to simply hit return if he wants to leave that value unchanged. Hints: Input all data using cin.getline, including the menu choice.

Evaluation

1.
Give two strengths of your group.
2.
Indicate two areas for improvement.
3.
What two new insights did your group obtain?
4.
Give two strengths of the class.
5.
Indicate two areas for improvement of the class.
6.
What two new insights did you obtain about the class?

next up previous
Up: Return
Author: Leon van Dommelen