Академический Документы
Профессиональный Документы
Культура Документы
PROJECT REPORT
ON
SHUFFLE GAME
Submitted towards the partial fulfillment of the requirement
for the award of the degree of MCA
SESSION: 2015-18
SUBMITTED TO : SUBMITTED BY :
Dr. Heman Pathak Diksha Kashyap
(MCA 3rd sem)
1
CERTIFICATE
This is to certify that the project work entitled SHUFFLE GAME has
been done by Diksha kashyap, student of MCA (III sem) of Kanya Gurukul
Campus, Dehradun, is an authentic work carried out by her at the Department
of Computer science under the supervision of Dr. Heman Pathak.
2
ACKNOWLEDGEMENT
3
CONTENTS
1.INTRODUCTION.............................................................................................
3.1Design Objectives....................................................................................10
3.2 Description of the project.......................................................................12
4.SOFTWARE DEVELOPMENT ENVIRONMENT.......................................13
7. CONCLUSION...............................................................................................26
8. SOURCE CODE.............................................................................................27
9.REFERENCES................................................................................................33
4
1.INTRODUCTION
Software is the part of the computer system, which enables the user to interact
with several physical hardware devices. The software requirement
specifications for developing this project are as follows:
5
Documentation Tool : MS Office
1. Enhancement:
The main objective of shuffle game is to enhance and upgrade the existing
system by increasing its efficiency and effectiveness.
2.Automation:
The Shuffle Game in C++ Language automates each and every activity of the
manual system and increases its throughput.
6
3.Accuracy:
The Shuffle Game provides the uses a quick response with very accurate
information regarding the users etc.
4. User-Friendly:
The software Shuffle Game has a very user-friendly interface. Thus the users
will feel very easy to work on it. The software provides accuracy along with a
pleasant interface.
5.Entertainment:
7
2.SYSTEM ANALYSIS
In system analysis we are analysing about the the system. A system analysis is
a separation of a substance into parts for study and their implementation and
detailed examination.
Before designing any system it is important that the nature of the business and
the way it currently operates are clearly understood. Analysis begins with
system initialization and continues until its maintenance. Even after
successful implementation of the system, analysis may play its role for
periodic maintenance and up gradation of the system.
The requirement is the feature that must be included in the project before the
actual implementation and actual design of the project start. Main emphasis
should be on following:
8
2.2 Input Required
The initial working of the project starts with a menu. Menu has two options
from which the user has to choose one option by entering the number(for
option first enter 1) corresponding to the option.
The shuffle game should begins successfully after providing the above
input.
The numbers must be shifted in the adjacent boxes easily by hitting the
key of the number that we want to shuffle.
If we complete the game in the given number of moves. Then the
message you have won is shown.
While if we are not able to arrange the numbers in ascending number
then another message should be displayed you have surpassed the
maximum number of moves
9
3.SYSTEM DESIGN
The systems objectives outlined during the feasibility study serve as the basic
from which the work of system design is initiated. Much of the activities
involved at this stage is of technical nature requiring a certain degree of
experience in designing systems, sound knowledge of computer related
technology and through understanding of computers available in the market
and the various facilities provided by the vendors
3.1Design Objectives
a)Practicality
The system must be stable and can be operated by people with average.
10
b)Efficiency
c)Flexibility
e)Security
This is very important aspect of the design and should cover areas of
hardware reliability, fall back procedures, physical security of data.
System design involves first logical design and then physical construction of
the system. The logical design describes the structure and characteristics of
features, like the outputs, inputs, files, database and procedures. The physical
construction, which follows the logical design, produces actual program
software, files and a working system.
11
3.2 Description of the project
Shuffle game is a brain teaser game.Initially all the numbers are shuffled and
displayed in random order. Arrange the numbers in ascending order from left
to right. Click on any number which is either left, right, top or down to the
empty button.
The game will be completed when all the numbers are arranged in sorted in
ascending order
We use the empty block to arrange the shuffled numbers into a particular
order.Order of the numbers can either be ascending or descending. We can
make the game according to our wish. I have used the C++ language for
making this project and compiled it using the TURBO C++ software.
12
4.SOFTWARE DEVELOPMENT ENVIRONMENT
C++ is a superset of C, and that virtually any legal C program is a legal C++
program.
13
It is necessary to understand some of the concepts used extensively in object-
oriented programming. These include:
Objects
Classes
Data abstraction and encapsulation
Inheritance
Polymorphism
Dynamic binding
Message passing
a) Objects
Objects are the basic run time entities in an object- oriented system. They
may represent a person, a place, a bank account, a table of data or any item
that the program has to handle.
b) Classes
The wrapping up of data and function into a single unit (called class) is
known as encapsulation. t. These functions provide the interface between the
objects data and the program. This insulation of the data from direct access
by the program is called data hiding or information hiding.
14
Abstraction refers to the act of representing essential features without
including the background details or explanation.
d) Inheritance
e) Polymorphism
f) Dynamic Binding
g) Message Passing
#include<iostream.h>
#include<stdlib.h>
#include<string.h>
#include<conio.h>
#include<ctype.h>
#include<dos.h>
#include<graphics.h>
#include<stdlib>
The name "stdlib" stands for "standard library"stdlib.h which includes
functions involving memory allocation, process control, conversions and
others
16
#include<iostream.h>
The manipulators in this library affect the format of stream operations. Note
that iomanip contains additional manipulators.
#include<string.h>
The string.h header defines one variable type, one macro, and various
functions for manipulating arrays of characters
#include<conio.h>
This header declares several useful library functions for performing "console
input and output" from a program.
#include<ctype.h>
The classification functions return a true value if ch belongs to the specified
group; otherwise they return false.
#include<graphics.h>
This interface provides access to a simple graphics library that makes it
possible to draw lines, rectangles, ovals, arcs, polygons, images, and strings
on a graphical window.
cleardevice erases the entire graphics screen and moves the CP (current
position) to home (0,0).
closegraph deallocates all memory allocated by the graphics system
initgraph initializes the graphics system by loading a graphics driver from
disk (or validating a registered driver) then putting the system into
graphics mode.
getbkcolor returns the current background color
setbkcolor sets the current background color using the palette
settextstyle sets the text font, the direction in which text is displayed,
and the size of the characters.
outtext displays a string in the viewport (graphics mode)
outtextxy displays a string at the specified location (graphics mode)
setcolor sets the current drawing color to color, which can range from 0 to
getmaxcolor.
18
#include<dos.h>
It contains functions for handling interrupts, producing sound, date and time
functions etc. It is a Borland specific and works in turbo c compiler.
I have included various header files that were required for the game.and the
member function under these header files are described above along with
their functionalities.
Now I want to discuss the various user defined functions along user defined
along with their working and use in the program.
As I have made the project in c++ language. So classes and objects are must
in the program. In my project I have used only one class named as class
shuffl .and I have declared all the variables as private and all the user defined
functions as public in the class.
void disp();
void printmenu();
void intro(void);
19
void levelmenu(void);
void easy();
void initial(int x);
void draw(int x, int y, int i);
void userwin(int no);
void disp();
it displays the lastmost output screen of the game showing the profile and
details of the programmer. It is implemented using the graphic functions.
Void printmenu();
Displays the main screen of the with the name of the game at the top of the
screen and the shortcut of the exit option. It also shows the number of moves
below the game layout.
void intro();
Intro function displays the very first output screen on which the title of the
project SHUFFLE GAME blinks in various colours. This is done using the
graphics functions.
It displays the second output screen which contains a menu. This menu asks
the user to enter a choice from the given two option.1. Start 2. Rules.
On selecting the first option the shuffle game window opens up and the game
begins. While on selecting the second option rules of the game are displayed
on the screen.
20
void easy();
for eg: you have won the game is displayed whenever the user completes
the game by arranging all the numbers in ascending order.
void check();
Check is the most important function of the whole game. it checks whether
the right number is placed in its correct block at the end of the game using the
given number of moves by following the particular algorithm using the switch
case.
void userwin();
If the value of the variable win decides whether user have won the game or
not.If has been assigned value true then user wins. If it has assigned value
false then user has not won.
void draw();
Draw function used to draw the grid layout of the shuffle game. i.e. the nine
rectangle boxes in which the numbers 1 to 8 are written and one block is left
blank.
21
5. PROJECT TESTING
1.Unit test
2.Integration test
3.Perfomance test
22
5.1 Unit Testing :-
The unit test is always while box oriented. The tests that accure as part of unit
testing are testing the module interface, examining the local data structures,
testing are the boundary conditions, execution all the independent paths and
testing error-handling paths.
Timing for both read and update transaction should be gathered to determine
whether system function are being performed in an acceptable timeframe.
23
6. SCREENSHOTS OF OUTPUT
24
25
7. CONCLUSION
The program meets the requirements of the project shuffle game to a great
degree. Shuffling of numbers was the most important function of the project
and shuffling of the numbers is being done correctly and smoothly.
All the header files, member functions, used defined functions and variables
of the class shuffle are functioning well and no error or warning is being
encountered while compiling the program.
Almost all the Graphics used in the program are working finely and the
output could be seen in the screenshots.
8. SOURCE CODE
26
#include<iostream.h>
#include<stdlib.h>
#include<string.h>
#include<conio.h>
#include<ctype.h>
#include<dos.h>
#include<graphics.h>
#define true 1
#define false 0
class shuffl
{
private:
int check(int key);
int load;
int i;
int step;
int level;
int num[25];
int win;
public:
void disp();
void printmenu();
void intro(void);
void levelmenu(void);
void easy();
void initial(int x);
void draw(int x, int y, int i);
void userwin(int no);
};
void shuffl::levelmenu() //displays the second output screen showing the menu of
{ the shuffle game
level=0;
clrscr();
cleardevice();
setbkcolor(BLACK);
settextstyle(1,0,4);
setcolor(GREEN);
outtextxy(200,100,"Press 1 to start");
outtextxy(200,120,"----------------");
outtextxy(200,140,"1. Start");
outtextxy(200,160,"2. Rules");
outtextxy(200,200,"Enter a choice: ");
gotoxy(50+4,22);
scanf("%d", &level);
if(level==2)
{
outtextxy(20,40,"Read the rules :");
outtextxy(20,80,"1: Arrange the numbers in ascending order");
outtextxy(20,120,"2: Press the no key to move the nos");
27
outtextxy(20,160,"3: X-Exit");
delay(10000);
}
}
void shuffl::intro()// displays the first output screen on which shuffle game blinks in
bold
{
int i,j;
clrscr();
cleardevice();
setbkcolor(BLACK);
gotoxy (25,12);
settextstyle(4,0,6);
for(i=0;i<=4;i++)
{
setcolor(i%16);
outtextxy(2,3,"SHUFFLE GAME");
settextstyle(1,0,8);
delay(100);
getch();
}
}
void shuffl::printmenu()//displays the main screen of the game
{
int i;
gotoxy(33,1);
cout<<"SHUFFLE GAME";
gotoxy(1,2);
for(i=0; i<80; i++)
cout<<"\xcd";
cout<<"\t\t\t\tX=exit game\n";
for(i=0; i<80; i++)
cout<<"\xcd";
gotoxy (35,23);
cout<<"Moves =""%d"<<step;
}
void shuffl::easy()// easy function controls the all functions done during the program
{
int i, x, y,key;
char press[2];
if(load==false)
initial(9);
else
load=false;
do
{
start:
printmenu();
i=0;
28
for(y=8; y<17; y+=4)
for(x=33; x<44; x+=5)
{
draw(x,y,i);
i++;
}
userwin(8);
if(win==true)
{
cleardevice();
outtextxy(2,2,"You have won the game");
delay(2000);
disp();
delay(2000);
win=false;
return;
}
gotoxy (55,17);cout<<"Tips:";
gotoxy (61,18);cout<<"Number will move";
gotoxy (61,19);cout<<"when you key in!";
gotoxy (43,23);fflush(stdin);
press[0]=toupper(getche());
if(press[0]=='X')
{
disp();
exit(1);
}
key=atoi(press);
if((check(key))==0)
{
goto start;
}
step++;
if(step==50)
{
cleardevice();
outtextxy(20,200,"YOU HAVE SURPASSED MAXIMUM POSSIBLE
MOVES");
delay(1500);
disp();
delay(2500);
exit(1);
}
for(i=0; i<9; i++)
{
if(num[i]==key)
num[i]=0;
else
if(num[i]==0)
num[i]=key;
29
}
}
while(1);
}
void shuffl::draw(int x, int y, int i)//it draws the rectangular boxes in the game
{
gotoxy (x,y);
if(level==1)
{
cout<<"%c%c%c",201,205,187;
gotoxy (x,y+1);
cout<<"%c",186;
if(num[i]==0)
cout<<" ";
else
cout<<"%d", num[i];
cout<<"%c",186;
gotoxy (x,y+2);
cout<<"%c%c%c",200,205,188;
}
}
void shuffl:: disp()//it displays the lastmost output screen after the exit
{
cleardevice();
setbkcolor(BLACK);
settextstyle(4,0,4);
setcolor(RED);
outtextxy(200,100,"PROGRMMED BY");
outtextxy(300,220,"Diksha kashyap");
30
outtextxy(300,260,"MCA 2nd sem");
delay(2500);
}
int shuffl:: check(int key)//it checks at the end of the game whether the game has been
completed successfully or not
{
int i, valid=0;
if(level==1)
for(i=0; i<9; i++)
{
if(num[i]==key)
{
valid=true;
switch(i)
{
case 0:
if(num[1]!=0 && num[3]!=0)valid=0;
break;
case 1:
if(num[0]!=0 && (num[2]!=0 && num[4]!=0))valid=0;
break;
case 2:
if(num[1]!=0 && num[5]!=0)valid=0;
break;
case 3:
if(num[0]!=0 && (num[4]!=0 && num[6]!=0))valid=0;
break;
case 4:
if((num[1]!=0 && num[3]!=0) &&
(num[5]!=0 && num[7]!=0))valid=0;
break;
case 5:
if(num[2]!=0 && (num[4]!=0 && num[8]!=0))valid=false;
break;
case 6:
if(num[3]!=0 && num[7]!=0)valid=0;
break;
case 7:
if(num[4]!=0 && (num[6]!=0 && num[8]!=0))valid=0;
break;
case 8:
if(num[5]!=0 && num[7]!=0)valid=0;
31
break;
default:
valid=0;
break;
}
}
}
return valid;
}
void shuffl:: userwin(int no)//it confirms the winning possibility by true or flase value of
win
{
int i;
for(i=0; i<no ; i++)
if(num[i]!=i+1)
{
win=false;
break;
}
else
win=true;
}
void main()
{
shuffl shl;
int gdriver = DETECT, gmode, errorcode;
initgraph(&gdriver, &gmode, "c:\\turboc3\\bgi");
shl.intro();
shl.levelmenu();
clrscr();
cleardevice();
setbkcolor(RED);
shl.easy();
}
32
9.REFERENCES
33