hi pll
with all this post im makin ill probably look like i only have problems :S, but well, books dont solve all my problems :S
so....
my todays problem is that i have to make a game that uses the random values of two dices, n accordin to the result of the sum up of them, the user, wins, losses or has to keep goin till he reaches the value he got at first place.
so its like this: for 7 n 11 at first shot, he wins, for numers 4, 5, 6, 8, 9 n 10, has to keep playing until gettin the same number, but if he gets 2, 3 or 12, he losses.
for the 4, 5, 6, 8, 9 n 10, will keep playing unless he gets a 7, wich means he losses again.
the first part, i got it n works perfectly, i mean, the dices have random values, they sum up right, n the messages that have to show, they show how they should.
the problem is when i have those number to keep playin, tried to put the code in different places, but doesnt take it.
// dados_ _ej-a-entregar.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include <iostream>
#include <time.h> //sirve para cuando se va a trabajar con horas
int _tmain(int argc, _TCHAR* argv[])
{
srand (time(NULL)); // para que tome la hora de la pc como numero random
using namespace std;
int d1, d2;
int suma = 0, punto = 0; // para valores de los dados
char game;
d1 = rand () % 6 + 1; // para que de los numeros de los dados en forma aleatoria
d2 = rand () % 6 + 1; // para que de los numeros de los dados en forma aleatoria
cout << " Wanna start?? " << "\n";
cout << " 1 - YES, OF COURSE jeje" << "\n";
cout << " 2 - NO, GET ME OUT OF HERE" << "\n";
cout << " ";
cin >> game;
while (game != '2')
{
cout << " first dice is... ";
cout << d1;
cout << "\n" << "\n";
cout << " second dice is... ";
cout << d2;
cout << "\n" << "\n" << "\n";
suma = d1 + d2;
cout << " the sum up is...: " << suma << "\n" << "\n";
switch (suma)
{
case 11:
cout << " YOU WON " << "\n" << "\n" << "\n" << "\n";
break;
case 7:
cout << " YOU WON " << "\n" << "\n" << "\n" << "\n";
break;
case 2:
cout << " YOU LOST " << "\n" << "\n" << "\n" << "\n";
break;
case 3:
cout << " YOU LOST " << "\n" << "\n" << "\n" << "\n";
break;
case 12:
cout << " YOU LOST " << "\n" << "\n" << "\n" << "\n";
break;
case 4:
cout << " 4 is your point " << "\n" << "\n" << "\n" << "\n";
suma = punto;
break;
case 5:
cout << " 5 is your point " << "\n" << "\n" << "\n" << "\n";
suma = punto;
break;
case 6:
cout << " 6 is your point " << "\n" << "\n" << "\n" << "\n";
suma = punto;
break;
case 8:
cout << " 8 is your point " << "\n" << "\n" << "\n" << "\n";
suma = punto;
break;
case 9:
cout << " 9 is your point " << "\n" << "\n" << "\n" << "\n";
suma = punto;
break;
case 10:
cout << " 10 is your point " << "\n" << "\n" << "\n" << "\n";
suma = punto;
break;
default: // I HAVE PROBLEMS WITH THIS
while ((suma = punto) && (suma !=7))
{
d1 = rand () % 6 + 1; // to dice start randomly
d2 = rand () % 6 + 1; // to dice start randomly
suma = d1 + d2;
switch (suma)
{
case 4:
cout << " 4 is your point " << "\n" << "\n" << "\n" << "\n";
suma = punto;
break;
case 5:
cout << " 5 is your point " << "\n" << "\n" << "\n" << "\n";
suma = punto;
break;
case 6:
cout << " 6 is your point " << "\n" << "\n" << "\n" << "\n";
suma = punto;
break;
case 8:
cout << " 8 is your point " << "\n" << "\n" << "\n" << "\n";
suma = punto;
break;
case 9:
cout << " 9 is your point " << "\n" << "\n" << "\n" << "\n";
suma = punto;
break;
case 10:
cout << " 10 is your point " << "\n" << "\n" << "\n" << "\n";
suma = punto;
break;
case 7:
cout << " YOU LOST"; //TILL HERE. THIS IS THE CODE TO KEEP PLAYIN THAT DOESNT WORK
}
}
}
cout << " Wanna play again?? " << "\n";
cout << " 1 - YES, OF COURSE jeje" << "\n";
cout << " 2 - NO, GET ME OUT OF HERE" << "\n";
cout << " ";
cin >> game;
cout << "\n" << "\n" << "\n" << "\n";
d1 = rand () % 6 + 1; // to dice start randomly
d2 = rand () % 6 + 1; // to dice start randomly
}
system ("PAUSE");
return 0;
}
the program is atached
tnks!! :P