Sie sind auf Seite 1von 23

2017

Computer
Science
Assignment
Snake And Ladder
A Program for A Game
Computer Science Project
Work
Session 2017-18

Guided By: Mr. Deepak Sahu Sir.


Presented By:
Nishi Gupta
Nazmeen Bano
Himanshi Raj
Class:11th “A”
We would like to express our special thanks of gratitude to our teacher

Shri Deepak Sahu sir as well as our principal Shri M.K. Tiwari sir

who gave us the golden opportunity to do this wonderful project to

make c++ game , which also helped us in doing a lot of Research

and we came to know about so many new things We are really

thankful to them.

Secondly we would also like to thank our parents and friends who

helped us lot in finishing this project within the limited time. We are

making this project not only for marks but to also increase my

knowledge.

THANKS AGAIN TO ALL WHO HELPED US.


 ACKNOWLEDGEMENT
 CERTIFICATE
 INTRODUCTION TO PROJECT
 HARDWARE AND SOFTWARE
 ABOUT C++ PROGRAMMING
LANGUAGE
 CODING
 OUTPUT
 CONCLUSION
 BIBLIOGRAPHY
This is to certify that Nishi Gupta of
class 11th Science ,session 2017 - 2018
completed this project of subject Computer
Science carefully and sincerely under
the guidance of Mr. Deepak Sahu .

TEACHER’S SIGN PRINCIPAL’S SIGN


This is to certify that Nazmeen Bano of
class 11th Science ,session 2017 - 2018
completed this project of subject Computer
Science carefully and sincerely under
the guidance of Mr. Deepak Sahu .

TEACHER’S SIGN PRINCIPAL’S SIGN


This is to certify that Himanshi Raj of
class 11th Science ,session 2017 - 2018
completed this project of subject Computer
Science carefully and sincerely under
the guidance of Mr. Deepak Sahu .

TEACHER’S SIGN PRINCIPAL’S SIGN


The program is made by using
advanced programming methodology.
It is based on a simple game which is
well known and is being played by
many users. The game is “Snake and
Ladder”. Many advanced techniques
and method are used for making this
game. The objective of this coding is to
provide its users with an opportunity to
play this game at the comfort of their
homes on a computer system.
HARDWARE – COMPUTER SYSTEM
SOFTWARE – TURBO C++
C++ is one of the most popular languages
primarily utilized with system/application
software, drivers, embedded firmware, etc.
C++ is a collection of pre-defined classes,
which are data types that can be instantiated
multiple times. The language also facilitates
declaration of user defined classes.
It is a programming language based on DOS
and contains various programming codes and
other advanced methods for making it ease
and comfortable for usage for a user.
#include<iostream.h>
#include<conio.h>
#include<stdlib.h>
#include<stdio.h>

void draw_line(int n,charch);


void board();
void gamescore(char name1[],char name2[],int p1, int p2);
void play_dice(int&score);

void main()
{
int player1=0,player2=0,lastposition;
char player1name[80],player2name[80];
clrscr();
randomize();
draw_line(50,'=');
cout<<"\n\n\n\n\t\tSNAKE LADDER GAME\n\n\n\n";
draw_line(50,'=');
cout<<"\n\n\nEnter Name of player 1 :";
gets(player1name);
cout<<"\n\n\Enter Name of player 2 :";
gets(player2name);
while(player1<=100 && player2<=100)
{
board();
gamescore(player1name,player2name,player1,player2);
cout<<"\n\n--->" <<player1name<<" Now your Turn >>
Press any key to play ";
getch();
lastposition=player1;
play_dice(player1);
if(player1<lastposition)
cout<<"\n\aOops!! Snake found !! You are at postion
"<<player1<<"\n";
else if(player1>lastposition+6)
cout<<"\nGreat!! you got a ladder !! You are at position
"<<player1;
cout<<"\n\n--->"<<player2name<<" Now your Turn >>
Press any key to play ";
getch();
lastposition=player2;
play_dice(player2);
if(player2<lastposition)
cout<<"\n\n\aOops!! Snake found !! You are at position
"<<player2<<"\n";
else if(player2>lastposition+6)
cout<<"\n\nGreat!! you got a ladder !! You are at position
"<<player2<<"\n";
getch();
}
clrscr();
cout<<"\n\n\n";
draw_line(50,'+');
cout<<"\n\n\t\tRESULT\n\n";
draw_line(50,'+');
cout<<endl;
gamescore(player1name,player2name,player1,player2);
cout<<"\n\n\n";
if(player1>=player2)
cout<<player1name<<" !! You are the winner of the
game\n\n";
else
cout<<player2name<<" !! You are the winner of the
game\n\n";
draw_line(50,'+');
getch();
}

void draw_line(intn,charch)
{
for(inti=0;i<n;i++)
cout<<ch;
}

void board()
{
clrscr();
cout<<"\n\n";
draw_line(50,'-');
cout<<"\n\t\tSNAKE AT POSITION\n";
draw_line(50,'-');
cout<<"\n\tFrom 98 to 28 \n\tFrom 95 to 24\n\tFrom 92 to
51\n\tFrom 83 to 19\n\tFrom 73 to 1\n\tFrom 69 to
33\n\tFrom 64 to 36\n\tFrom 59 to 17\n\tFrom 55 to
7\n\tFrom 52 to 11\n\tFrom 48 to 9\n\tFrom 46 to
5\n\tFrom 44 to 22\n\n";
draw_line(50,'-');
cout<<"\n\t\t LADDER AT POSITION\n";
draw_line(50,'-');
cout<<"\n\tFrom 8 to 26\n\tFrom 21 to 82\n\tFrom 43 to
77\n\tFrom 50 to 91\n\tFrom 62 to 96\n\tFrom 66 to
87\n\tFrom 80 to 100\n";
draw_line(50,'-');
cout<<endl;
}

void gamescore(char name1[],char name2[],int p1, int p2)


{
cout<<"\n";
draw_line(50,'~');
cout<<"\n\t\tGAME STATUS\n";
draw_line(50,'~');
cout<<"\n\t--->"<<name1<<" is at position
"<<p1<<endl;
cout<<"\t--->"<<name2<<" is at position "<<p2<<endl;
draw_line(50,'_');
cout<<endl;
}
void play_dice(int&score)
{
int dice;
dice=random(6)+1;
cout<<"\nYou got "<<dice<<" Point !! ";
score=score+dice;
cout<<"Now you are at position "<<score;
switch(score)
{
case 98 :score=28;break;
case 95 :score=24;break;
case 92 :score=51;break;
case 83 :score=19;break;
case 73 :score=1;break;
case 69 :score=33;break;
case 64 :score=36;break;
case 59 :score=17;break;
case 55 :score=7;break;
case 52 :score=11;break;
case 48 :score=9;break;
case 46 :score=5;break;
case 44 :score=22;break;
case 8 :score=26;break;
case 21 :score=82;break;
case 43 :score=77;break;
case 50 :score=91;break;
case 54 :score=93;break;
case 62 :score=96;break;
case 66 :score=87;break;
case 80 :score=100;
}
}
I conclude based upon the foregoing
that my game in our analysis is
correct and predict that my margins of
error is within tolerant limits, hence
snake and ladder game is made.

Sumita arora c++ class 11th , Internet .

Das könnte Ihnen auch gefallen