Unformatted text preview:

driver cpp driver program to demonstrate the behavior of the Triangle class MAIN Driver include iostream include iomanip include triangle h using namespace std int main set decimal outputs to 2 decimal places cout setiosflags ios fixed ios showpoint setprecision 2 create some Triangles Triangle t1 5 t2 7 t3 12 X O t4 50 o display original Triangles cout t1 has size t1 GetSize units n t1 Draw cout nt2 has size t2 GetSize units n t2 Draw cout nt3 has size t3 GetSize units n t3 Draw cout nt4 has size t4 GetSize units n t4 Draw cout n t1 Shrink demonstrate shrink t2 Shrink t3 Grow and grow t4 Grow cout t1 now has size t1 GetSize units n cout t2 now has size t2 GetSize units n cout t3 now has size t3 GetSize units n cout t4 now has size t4 GetSize units n demonstrate perimeter cout t2 has perimeter t2 Perimeter units n cout t3 has perimeter t3 Perimeter units n and area cout t2 has area t2 Area square units n n cout t3 has area t3 Area square units n n t1 Draw t1 Grow show that fill character cout t1 grows n appears only when size t1 Draw is at least 3 t1 Grow cout and grows n t1 Draw cout n t1 t2 demonstrate the default overload of the assignment operator cout t1 now has size t1 GetSize units n t1 Draw demonstrate the changing of border and fill characters t2 SetBorder t2 SetFill cout t2 now looks like n t2 Draw cout n t2 SetBorder n illegal border t2 SetFill a illegal fill cout t2 now looks like n t2 Draw cout n cout nHere is a summary on t3 n demonstrate summary t3 Summary return 0 END MAIN CPP triangle cpp file include iostream include cmath include iomanip include triangle h using namespace std default constructor Triangle Triangle int l char b char f if l 1 length 1 else if l 39 length 39 else length l SetBorder b SetFill f int Triangle GetSize return length void Triangle SetBorder char b if validChar b border b else border return void Triangle SetFill char f if validChar f fill f else fill return bool Triangle validChar char c int intVal static cast int c if intVal 33 intVal 126 return false return true else int Triangle Perimeter return 3 length returns length of all sides double Triangle Area cout fixed setprecision 2 double A pow length 2 static cast double sqrt 3 4 return A void Triangle Draw if length 1 cout border return else if length 2 cout border endl cout border border if length 2 for int i 1 i length i for int j 0 j length i j cout cout border cout fill for int j 0 j i j if j 1 i length else if i length j length 2 cout cout border if i 1 cout endl cout border void Triangle Grow if length 39 length void Triangle Shrink if length 0 length void Triangle Summary return return return return header file for triangle class Triangle public private int length char border char fill cout Size of triangle s side GetSize units n cout Perimeter of triangle Perimeter units n cout Area of triangle Area units n cout Triangle looks like endl Draw END CPP H Triangle int l char b char f int GetSize int Perimeter double Area void Draw void Grow void Shrink void SetBorder char void SetFill char void Summary bool validChar char returns size of a side returns the perimeter returns the area displays triangle increases size of triangle by 1 decreases size of triangle by 1 mutator mutator output summary END H


View Full Document

FSU COP 3330 - Assignment

Download Assignment
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view Assignment and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view Assignment 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?