//cadoop.c #include "stdio.h" //OOP //the x and y positions are common to all objects, and should be able to be //abstracted. we can do this using the "class" definition, and makeing a //standard "cad-class" which will contain the basic blueprints for every //object in the cad system. class cad_object { int positionx; int positiony; public: int number; void print_properties(void) { printf("xposition of rectangle%d is %d\n", number, positionx); printf("yposition of rectangle%d is %d\n", number, positiony);} void get_properties(void) { printf("xposition of rectangle?"); scanf("%d", &positionx); printf("yposition of rectangle?"); scanf("%d", &positiony); } }; class rectangle : cad_object { int height; int length; public: void print_properties(void) { cad_object::print_properties(); printf("height of rectangle%d is %d\n", number, height); printf("length of rectangle%d is %d\n", number, length); }; void get_properties(void) { cad_object::get_properties(); printf("height of rectangle?"); scanf("%d", &height); printf("length of rectangle?"); scanf("%d", &length); }; }; class circle : cad_object{ int radius; public: void print_properties() { cad_object::print_properties(); printf("radius of circle%d is %d\n", number, radius); }; void get_properties() { cad_object::get_properties(); printf("radius of circle?"); scanf("%d", &radius); } }; int main(void){ rectangle rectangle1; rectangle rectangle2; rectangle1.get_properties(); rectangle2.get_properties(); rectangle1.print_properties(); rectangle2.print_properties(); circle circle1; circle circle2; circle1.get_properties(); circle2.get_properties(); circle1.print_properties(); circle2.print_properties(); };