if(a == b)
{
a = a * 2;
b = b - 1;
}
NOT as:
if(a == b)
{
a = a * 2;
b = b - 1;
}
If you use vim on Sleipnir, it will indent such blocks automatically for you.
Shape
/ \
/ \
Line Circle
Your main() function MUST have a pointer variable
of type Shape that will be used to store the current shape. Remember to delete
the current shape before allocating a new one. You will then call the
set_shape() and print_shape() member functions using
this parent class pointer. See
pointer_example.cpp
for an example of this.
Your menu should be as follows:
Welcome to the Shape Menu =========================== 1. Create a new line 2. Create a new circle 3. Print the current shape 0. Exit ===========================Options 1 and 2 should try to allocate a new line or circle object, check that the new line/circle was actually allocated and print a message if the allocation failed. Be SURE to deallocate any old shape before allocating a new shape when Option 1 or 2 is selected.
If the allocation works, Option 1 should prompt the user for the x,y
coordinates of the origin of the line and the length of the line. It should
then read those values into temporary integers. It should then call
set_shape() to pass the values into the Line object.
Likewise, if allocation works, Option 2 should prompt for the x,y coordinates
of the origin of the circle and the radius of the circle, read those values
into temporary integers and call set_shape() to pass those values
into the Circle object.
Option 3 should gracefully handle the case where 3 is selected before 1 or 2
(i.e. when there is no shape object allocated). It should print an error
message about no shape existing (core dumps when 3 is selected first will be
a deduction in your grade). If there is a shape allocated, Option 3 should
call print_shape() to print information about the shape.
Submit your completed code as an attachment in an email to the instructor. If you use multiple files (seperate compilation), be sure to include all files in the attachment list.