This
is a Character based User Interface or CUI based simple computerized solution
to manage the system activities. This prototype code saves time and energy of
its user by automating certain tasks. This system is either file handling type
or ROM type, and stores activities in a coder-defined file or on ROM memory
temporarily.
C++
is a typed language, so no need of code explanation as everything will be
cleared by itself by reading the code. If you know C++, you know this code.
It’s that simple!
Note
to students, draw a class diagram and flow chart of system by reading the code
itself. The Code::Blocks IDE 20.03+MinGW and Cygwin tool are used to test the
code.
Note
that some systems are very simple and need enhancement but they are complete on
their own in other terms.
|
RaceOfDrunkManfromStarttoFinishAnimation.cpp |
|
|
#include<iostream> #include<cmath> #include<cstdlib> #include<ctime> using namespace std; int main () { srand(time(0)); const int size=60; cout << "Enter a letter to
begin \n "; char x; cin>> x; int position = size /2; while (true) { cout << "|START|" ; for (int i=0; i<size; i++) { if (i == position) cout << x; else cout << " "; } cout << "|FINISH|"
<< endl; int move= rand()%3 - 1; position = position + move; if (position <1) { cout << "You could not
finish the race!" <<endl; break; } if (position >size-1) { cout << "Yay! You
finished the race" << endl; break; } for(int sleep=0; sleep< 1000000 ;
++ sleep); } return 0; } |
|
|
For more C/C++ codes related information click here. …till next post, bye-bye and take care. |
|
No comments:
Post a Comment