Mapua Institute of Technology
Muralla St. Intramuros, Manila
MACHINE PROJECT
CS10L/COMPUTER SCIENCE LABORATORY
Submitted by: Barrientos, Lei Anne Catenza, Lorraine Gavino, Regina Lim, Tinnie Maglaki, Trixie Julianne
Submitted to: Engr. Cheryl Mari M. Isip
2nd Quarter / SY 2011-2012
I.
Machine Program Statement The program is entitled Memory Game. The program will contain ten levels, wherein in each level, there will be a statement that will be displayed for a certain time, and will disappear afterwards. The user needs to input the same statement, with the proper punctuations and capitalizations observed, until one reaches level ten.
II.
Objective/s The main objective of the game is to enhance the memory skills of the user into familiarizing long, substantial statements.
III.
Data Dictionary Functions Description Main function of the program Function for timer Function that outputs the statements
Function Name int main void wait Void print
Return Type Integer Void Void
Parameter None int seconds int lv and int time
Identifier Name lvl time yn answer lv
Data Type int int char string int
Variables Local to Description int main () Level of the game int main () Default starting time for timer int main () Starter of the game int main () Container for the answer of the user void print () Variable for the array
IV.
Program Flowchart
V.
Screenshots
VI.
Program listing (codes)
#include <iostream> #include <string> #include <time.h> using namespace std; string phrases[] = {"Let bygones be bygones.", "Criticizing is easy, art is difficult.", "Don't look where you fall but where you slipped.", "Education is not filling a bucket but lighting a fire.", "It does not do to dwell on dreams and forget to live.", "I can do all things through Christ who strengthens me.", "Art washes away from the soul the dust of everyday life.", "An investment in knowledge always pays the best interest.", "He who knows others is learned; he who knows himself is wise.", "If you are not part of the cure, then you are part of the problem."};
void wait( int seconds ) { clock_t endwait; endwait = clock () + seconds * CLOCKS_PER_SEC ; while (clock() < endwait) {} system("cls"); }
void print( int lv , int time ) { time *= lv; cout << "Memorize the phrase in " << time << " seconds \n"; cout << phrases[lv - 1]; wait( time ); } int main() { int lvl = 1 , time = 3; char yn; string answer; cin >> yn; system("cls"); do{ print ( lvl , time ); getline (cin,answer); if ( answer == phrases[ lvl - 1 ] ){ lvl += 1 ; continue; } else lvl = 1; if (lvl == 10) break; } while (lvl != 10); cout << " Do you want to retry the game (y/n)?: "; cin >> yn; if ( yn == 'y') main(); else if ( yn == 'n' ) return 0; else {cin >> yn; return 0;} }
VII.
Group Contribution Member s Name Regina Gavino Trixie Maglaki Tinnie Lim Lorraine Catenza Lei Barrientos Contribution Flowchart, encoding, paperworks, CD burning Encoding Encoding Encoding, paperworks Encoding, paperworks Module Programmed Compiled all the functions into one Wait function and Print function Wait function and Print function Main function Main function