Sei sulla pagina 1di 33

A

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)

KANYA GURUKUL CAMPUS, DEHRADUN


AFFILIATED TO GKV, HARIDWAR (U.K.)

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.

DR. HEMAN PATHAK


Associative professor
Dept of Comp. Science

2
ACKNOWLEDGEMENT

I Would like to express my profound gratitude and thanks to respected


Dr. Heman Pathak for her immense support, valuable guidance and
advices during the preparation of this seminar. She helped nurse this
project from idea of stage to the record. I tried my maximum to make
seminar according to her suggestion and direction.

Date. Diksha kashyap

3
CONTENTS

1.INTRODUCTION.............................................................................................

1.1 Problem Defination...............................................................................5


1.2 H/W and S/W specification......................................................................5
2.SYSTEM ANALYSIS.......................................................................................

2.1 Planning and requirement.........................................................................8


2.2 Input Required..........................................................................................9
2.3 Output expected........................................................................................9
2.4 Smooth Termination.............................................................................9
3.SYSTEM DESIGN..........................................................................................10

3.1Design Objectives....................................................................................10
3.2 Description of the project.......................................................................12
4.SOFTWARE DEVELOPMENT ENVIRONMENT.......................................13

4.1 Overview of C++....................................................................................13


4.2 Description of the Header files used.......................................................16
4.3 Description of user defined function......................................................19
5. PROJECT TESTING......................................................................................22

5.1 Unit Testing ...........................................................................................23


5.2 Integration Testing..................................................................................23
5.3 Performance Testing...............................................................................23
6. SCREENSHOTS OF OUTPUT.....................................................................24

7. CONCLUSION...............................................................................................26

8. SOURCE CODE.............................................................................................27

9.REFERENCES................................................................................................33

4
1.INTRODUCTION

I m going to present my mini project on a very interactive and fun game


which is very user friendly and easy to play.

Title of the project is SHUFFLE GAME.

1.1 Problem Defination


Shuffle game is a number arranging puzzle game in which we take all
numbers from 1 to 8 randomly and our aim to arrange all the numbers in
order that is 1 to 8 and one vacant space is filled by number 0.This game is
best suited for engineering students to increase mind power and thinking
capacity.

1.2 H/W and S/W specification

a) Software Requirement Specification

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:

Operating System : Window 7(ultimate)

Presentation layer : CPP

5
Documentation Tool : MS Office

b) Hardware Requirement Specification

The collection of internal electronic circuits and external physical devices


used in building a computer is called the Hardware. The minimum hardware
requirement specifications for developing this project are as follows:

Processor : Standard processor with a speed of 1.6 GHz or more

RAM : 256 MB RAM or more

Hard Disk : 20 GB or more

Monitor : Standard color monitor

1.3 OBJECTIVE of the project

The Shuffle Game In C Language eliminates most of the limitations of the


existing software. It has the following objectives:

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:

Shuffle game could also be a source of refreshment and entertainment for


students in their free time of the day.

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.

2.1 Planning and requirement

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:

The input of the system


The output expected from the system
The volume of the data (input) and the amount of information (output)
that will be involved
The main points of application
The processing rules of collected data
The expectation that may be present

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.

By choosing the first option user can start the game.


By chossing the second option user can read the rules of the game
After starting the game if the user want to leave the game at any point
of time then he can easily exit the game by pressing the X.

2.3 Output expected

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

2.4 Smooth Termination

After the successful working of the program and various functions


included in the program the proper termination of the game must be
done.
A blank window saying THANKYOU FOR PLAYING thanking the
user could be used instead of exiting the game at once.

9
3.SYSTEM DESIGN

System design is a solution, a HOW TO approach to the creation of a new


system. It translates system requirements into ways by which they can be
made operational. It is a translational from a user oriented document to a
document oriented programmers. For that, it provides the understanding and
procedural details necessary for the implementation.

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

System Design Considerations

The system design process is not a step-by-step adherence of clear procedures


and guidelines. Design work depends on knowledge and experience of the
designer.When designer starts working on system design, he will face
different type of problems. Many of these will be due to constraints imposed
by the user or limitations of the hardware and software available in the market

3.1Design Objectives

The primary objective of the design of course, is to deliver the requirements


as specified in the feasibility reports. In general the following design
objectives should be kept in mind.

a)Practicality

The system must be stable and can be operated by people with average.
10
b)Efficiency

This involves accuracy, timeliness and comprehensiveness to the system


output

c)Flexibility

The system should be modifiable depending on the changing needs of the


user. Such modifications should not entail extensive reconstructing or
recreation of software. It should also be portable to different computer
systems.

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

Figure 1: The shuffle game sample layouts

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

4.1 Overview of C++

C++ is a statically typed, compiled, general-purpose, case-sensitive, free-form


programming language that supports procedural , object-oriented , and
generic programming. It is regarded as a middle-level language, as it
comprises a combination of both high-level and low-level language features.

C++ was developed by Bjarne Stroustrup starting in 1979 at Bell Labs in


Murray Hill, New Jersey, as an enhancement to the C language and originally
named C with Classes but later it was renamed C++ in 1983.

C++ is a superset of C, and that virtually any legal C program is a legal C++
program.

Some of the features of object oriented programming are:

Emphasis is on data rather than procedure.


Programs are divided into what are known as objects.
Data structures are designed such that they characterize the objects.
Functions that operate on the data of an object are ties together in the
data structure.
Data is hidden and cannot be accessed by external function.
Objects may communicate with each other through function.
New data and functions can be easily added whenever necessary.
Follows bottom up approach in program design.

Basic Concepts of Object Oriented Programming

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

Some concepts in detail are:

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

A class is thus a collection of objects similar types. Classes are user-defined


that types and behave like the built-in types of a programming language.

c) Data Abstraction and Encapsulation

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

Inheritance is the process by which objects of one class acquired the


properties of objects of another classes. It supports the concept of hierarchical
classification . In OOP, the concept of inheritance provides the idea of
reusability.

e) Polymorphism

Polymorphism is another important OOP concept. Polymorphism, means the


ability to take more than on form. An operation may exhibit different
behavior is different instances. The behavior depends upon the types of data
used in the operation.

f) Dynamic Binding

Binding refers to the linking of a procedure call to the code to be executed in


response to the call. Dynamic binding means that the code associated with a
given procedure call is not known until the time of the call at run time. It is
associated with polymorphism and inheritance.

g) Message Passing

An object-oriented program consists of a set of objects that communicate with


each other. The process of programming in an object-oriented language,
involves the following basic steps:

Creating classes that define object and their behavior,


Creating objects from class definitions, and
Establishing communication among objects.
15
4.2 Description of the Header files used

Header files contain definitions of Functions and Variables, which is


imported or used into any C++program by using the pre-processor #include
statement. Header file have an extension ".h" which contains C++ function
declaration and macro definition.

Various header files used in this project are:

#include<iostream.h>
#include<stdlib.h>
#include<string.h>
#include<conio.h>
#include<ctype.h>
#include<dos.h>
#include<graphics.h>

All header files with their member functions are as follows:

#include<stdlib>
The name "stdlib" stands for "standard library"stdlib.h which includes
functions involving memory allocation, process control, conversions and
others

abort Terminates program execution abnormally


abs Returns the absolute value of an integer
atof Converts a string argument to floating point
atoi Converts a string argument to an integer
exit Terminates program execution
rand() Generates an unsigned int between 0 and RAND_MAX, a named
constant
defined in cstdlib header file

16
#include<iostream.h>
The manipulators in this library affect the format of stream operations. Note
that iomanip contains additional manipulators.

dec Tells subsequent operation to use decimal representation


end1 Inserts new-line character \n and flushes output stream
ends Inserts null character \0 in an output stream
flush Flushes an output stream
hex Tells subsequent I/O operations to use hexadecimal
representation
oct Tells subsequent I/O operation to use octal representation
ws Extracts whitespace characters on input stream

#include<string.h>
The string.h header defines one variable type, one macro, and various
functions for manipulating arrays of characters

Strcat(toS, fromS) Copies fromS to the end of toS


Strncat(toS, fromS, n) Copies at most n characters of fromS to the end
of toS and appends \0
strcmp(str1, str2) Returns an integer that is negative if str1 < str2,
zero if str1 == str2, and positive if str1 > str2
stricmp(str1, str2) Behaves like strcmp, but ignores case
strncmp(str1, str2, n) Behaves like strcmp, but compares the first
n characters of each string
strcpy(toS, fromS) Copies fromS toS

#include<conio.h>
This header declares several useful library functions for performing "console
input and output" from a program.

kbhit - Determines if a keyboard key was pressed.


getch - Reads a character directly from the console without buffer, and without
echo.
getche - Reads a character directly from the console without buffer, but with echo.
cgets - Reads a string directly from the console.
cscanf - Reads formatted values directly from the console.
cputs - Writes a string directly to the console.
17
cprintf - Formats values and writes them directly to the console.
clrscr - Clears the screen.

#include<ctype.h>
The classification functions return a true value if ch belongs to the specified
group; otherwise they return false.

isalnum(ch) Returns true if ch is either a letter or a decimal digit


isalpha(ch) Returns true if ch is a letter
iscntrl(ch) Returns true if ch is a control character (ASCII 127 or 0 to 31)
isdigit(ch) Returns true if ch is a decimal digit
isgraph(ch) Returns true if ch is printable and nonblank
islower(ch) Returns true if ch is a lowercase letter
isprint(ch) Returns true if ch is printable (including blank)
ispunct(ch) Returns true if ch is a punctuation character
Returns true if ch is a whitespace character: space, tab, carriage return,
isspace(ch)
new line, or form feed

#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.

delay, the current program is suspended from execution for


the time specified by the argument milliseconds.
getdate fills in the dosdate_t structure *datep with the system's
current date.
sleep the current program is suspended from execution for
the number of seconds specified by the argument seconds.
nosound turns the speaker off after it has been turned on by a call to
sound.
gettime fills in a time structure with the system's current time

4.3 Description of user defined function

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.

The user defined functions are as follows:

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);

some of the user defined functions are defined below:

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.

void levelmenu ();

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();

Easy function is used for displaying the various messages and


acknowledgements whenever an event is encountered during the game.

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

Project Testing is the major control measure used during software


development. Its basic function is to detect errors in the software. During
requirement analysis and design, the output is a document that is usually
textual and no executable. After the coding phase, computer programs are
available that can be executed for testing purpose. This implies that testing
not only, has to uncover errors introduced during coding, but also errors
introduced during previous phase. Thus the goal of testing is to uncover the
requirements, design and coding errors in the programs. The Source code
declared above for the program of Scientific Calculator has been tested and it
has been found that the above source code is okay and correct.The program
involves many type of conversions. These conversions has to done
carefully.

SOFTWARE TESTING STRATEGIES :-

Testing is a set of activites that can be planned in advanced and conducted


systematically. A strategy for software testing must accommodation low-level
tests that are necessary to verify that a small source code segment has been
correctly implemented as well as high level tests that validate major system
functions against customer requirements.

There are three types of testing strategies.

1.Unit test
2.Integration test
3.Perfomance test

22
5.1 Unit Testing :-

Unit testing focuses verification efforts on the smallest unit of software


design module.

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.

5.2 Integration Testing :-

Integration Testing is a systematic technique or construction the program


structure while at the same time conducting testing tests to uncover errors
associated with interface. Scope of summarizes the specific functional,
performance and internal design characteristics that are to be tested. It
employs top-down testing and bottom-up testing methods for this case.

5.3 Performance Testing :-

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:: initial(int x)


{
int i,no;
step=0;
no=0%x;
if(no==1)
no+=5;
for(i=0; i<x; i++)
{
num[i]=no;
no+=2;
if(no>=x)
if(!(no%2))
no=1;
else
no=0;
}
}

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

The complete reference c++ by Herbert schildt


Programming in c++by E. balagurusamy
www.google.com
www.programmingincpp.com
www.codeincodeblock.com
projectsgeek.com
www.sourcecodesworld.com

33

Potrebbero piacerti anche