// File name: figure.cpp // Author: Xiannong Meng // Date: January 16, 1997 // Course: CS2330 // Assignment: classroom demonstration // Problem statement: This program draws a simple figure // using line segments. #include // function declarations void DrawCircle(); void DrawTriangle(); void DrawIntersect(); void DrawBase(); void main(void) { DrawCircle(); DrawTriangle(); DrawIntersect(); } // Name: DrawCircle() // Intent: Draw a psudo-circle using '*' // Pre-condition: None. // Post-condition: A circle is drawn on the standard output void DrawCircle() { cout << " *" << endl; cout << " * *" << endl; cout << " * *" << endl; } // Name: DrawTriangle() // Intent: Draw a triangle using '*' // Pre-condition: None. // Post-condition: A triangle is drawn on the standard output void DrawTriangle() { // Draw two intersecting lines first. DrawIntersect(); // Then draw the baseline. DrawBase(); } // Name: DrawIntersect() // Intent: Draw two intsercting lines, upper part of a triangle // Pre-condtion: None // Post-condition: Two intsercting lines are drawn. void DrawIntersect() { cout << " /\\" << endl; cout << " / \\" << endl; cout << " / \\" << endl; } // Name: DrawBase() // Intent: Draw a baseline as part of a triangle // Pre-condition: Two intersecting lines should have been drawn before this. // Post-condition: by drawing this base line, a triangle should be formed. void DrawBase() { cout << " -------" << endl; }