Learning to learn is essential to make you into an engineer who can stay up-to-date throughout your long carreer.
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.
$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).
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);}
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(...).
cin.getline, including the menu choice.