Thursday, 28 March 2013

C++ Casino Game Project

About The Project : 


Casino Game is very simple text based game designed in C++ Programming. In this game also we have not used any graphics. So this is simple project for beginners like 11th or 12th class student can learn basic project concept by my this article. In Casino Game player can deposit fund to play. From this amount he can bet on number between 1 to 12.  By winning game player will get 10 times of his fund or else will loss all fund.



Source Code : 


<pre class="brush: cpp">
#include&lt;iostream.h&gt;
#include&lt;conio.h&gt;
#include&lt;stdlib.h&gt;
#include&lt;stdio.h&gt;
#include&lt;time.h&gt;
void draw_line(int n,char ch);
void rules();
void main()
{
int balanceamt,amt,no,dice;
char playername[80],ch;
clrscr();
draw_line(60,'=');
cout&lt;&lt;"nnnnttCASINO GAMEnnnn";
draw_line(60,'=');
cout&lt;&lt;"nnnEnter Your Name :";
gets(playername);
cout&lt;&lt;"nnEnter Deposit amount to play game :";
cin&gt;&gt;balanceamt;
do
{
clrscr();
rules();
cout&lt;&lt;"nnYour current balance is Rs."&lt;&lt;balanceamt;
do
{
cout&lt;&lt;"nn"&lt;&lt;playername&lt;&lt;" enter money to bet";
cin&gt;&gt;amt;
if(amt&gt;balanceamt)
cout&lt;&lt;"Your betting amount is more than your current balancennRe-enter datan ";
else
break;
}while(1);
do
{
cout&lt;&lt;"Enter your lucky number to bet between 1 to 12 :";
cin&gt;&gt;no;
if(no&lt;=0||no&gt;12)
cout&lt;&lt;"Please check the number!! should be between 1 to 12nnRe-enter datan ";
else
break;
}while(1);
randomize();
dice=random(12)+1;
if(dice==no)
{
cout&lt;&lt;"nnGood Luck!! You won Rs."&lt;&lt;amt*10;
balanceamt=balanceamt+amt*10;
}
else
{
cout&lt;&lt;"Bad Luck this time !! You lose Rs."&lt;&lt;amt;
balanceamt=balanceamt-amt;
}
cout&lt;&lt;"nnThe winning number was : "&lt;&lt;dice;
cout&lt;&lt;"nnt"&lt;&lt;playername&lt;&lt;" You have Rs. "&lt;&lt;balanceamt&lt;&lt;endl;
cout&lt;&lt;"nn--&gt;Do you want to play (y/n)? ";
cin&gt;&gt;ch;
}while(ch=='Y'|| ch=='y');
clrscr();
cout&lt;&lt;"nnn";
draw_line(70,'+');
cout&lt;&lt;"nntTHANKS FOR COME TO CASINO YOUR BALANCE AMOUNT IS RS."&lt;&lt;balanceamt&lt;&lt;"nn";
draw_line(70,'+');
cout&lt;&lt;"nnGame developed by ANIKET RAJPUTn";
draw_line(70,'+');
getch();
}
void draw_line(int n,char ch)
{
for(int i=0;i&lt;n;i++)
cout&lt;&lt;ch;
}
void rules()
{
clrscr();
cout&lt;&lt;"nn";
draw_line(60,'-');
cout&lt;&lt;"nttRULES OF THE GAMEn";
draw_line(60,'-');
cout&lt;&lt;"nt1. Choose any number between 1 to 12nt2. If you win you will get 10 times of money you betnt3. If you bet on wrong number you will lose your betting amountnn";
draw_line(60,'-');
cout&lt;&lt;endl;
}
</pre>