/* import stream specification */ #include /* import Tank specification */ #include "Tank.h" /* Every C program starts with a function called main */ int main() { /***** Declaration section ******/ Tank ta; double h; /* Tell someone what this program does */ printf("Simple test of Tank class\n"); /****** Executable statement section *******/ /* Construct a tank and assign it to ta */ ta = ConsTank( 3.0, 4.0, 2.0 ); /* Assign a safe capacity */ if ( SetSafeCap( ta, 20.0 ) ) { printf("Safe capacity set: remaining volume = %f m^3\n", RemVol( ta ) ); /* Add some liquid */ if ( Fill( ta, 15.0 ) ) { printf("Tank now contains %f m^3\n", CurVol( ta ) ); if ( Drain( ta, 5.0 ) ) { printf("After drain: cur vol %f m^3, remaining %f m^3\n", CurVol( ta ), RemVol( ta ) ); } else printf("Drain error: should return TRUE\n"); } else printf("Fill error: should return TRUE\n"); } else printf("SetSafeCap error: should return FALSE\n"); /* Since main is a function, return something to indicate everything is OK */ return 0; }