the second edition, it is a prentice hall.
Do anybody know if i can download the complete book "statics and Mechanics of Materials" by R.C. Hibbeler?
Download MIRC (www.mirc.com), join the Undernet server, and try the channel #bookz
Most complete source of ebook material, excluding the gutenberg press, that I've found.
Reply:try edonkey or emule
theyve got everything.
Tuesday, July 14, 2009
Please help me rewrite this poker game C++ code and make it work...?
#include %26lt;iostream%26gt;
#include %26lt;string%26gt;
#include %26lt;time.h%26gt;
using namespace std;
class cCard
{
public:
char face[13] = {'2', '3', '4', '5', '6', '7', '8', '9', 'T', 'J', 'Q', 'K', 'A'};
enum suit[4] = {"S", "H", "D", "C"};
int getSuit ();
int getFace();
void print();
};
int cCard::getSuit()
{
return suit;
}
int cCard::getFace()
{
return face;
}
void cCard::print()
{
std::cout%26lt;%26lt;face %26lt;%26lt;suit;
}
class cDeck
{
public:
void shuffle();
char Card[13][4];
void Deck;
};
void cDeck::shuffle()
{
int face, suit;
for(face = 2; face %26lt; 13; face++)
{
for(suit = 0; suit %26lt; 4; suit++)
Card[face][suit] = NULL;
}
}
void cDeck::Deck()
{
int card, suit, face;
int deck[deckSuit][deckFace];
card = 1 ;
for (suit = 0 ; suit %26lt;= deckSuit - 1 ; suit++ )
{
for (face = 0 ; face %26lt;= deckFace - 1 ; face++ )
{
deck[suit][face] = card ;
card++;
}
}
}
class cPlayer
{
public:
string cPlayer();
void printHand();
void print();
};
string cPlayer::cPlayer(string name, int stake)
{
playerName = name;
playerStake = stake;
}
void cPlayer::printHand()
{
std::cout%26lt;%26lt;Card%26lt;%26lt;"\tab"%26lt;%26lt;Card%26lt;...
}
void cPlayer::print()
{
cout%26lt;%26lt;name %26lt;%26lt;" $" %26lt;%26lt;stake %26lt;%26lt;"\n";
}
class cGame
{
public:
bool addPlayer();
void play();
void deal();
void cardQuality();
void print();
};
bool cGame::addPlayer(string playerName, int playerStake)
{
std::cout %26lt;%26lt; "Enter your name: ";
std::cin %26gt;%26gt; playerName;
std::cout %26lt;%26lt; "\nHow much money you have for the game? ";
std::cin %26gt;%26gt; playerStake;
}
void cGame::play(int player[][2] , int shuffledCard[][13])
{
int sCard, sSuit, sFace, pSuit = 0 , pFace = 0;
static int cardStart = 1;
for (sCard = cardStart ; sCard %26lt;= cardStart + 4; sCard++ ) {
for (sSuit = 0 ; sSuit %26lt;= 3; sSuit++ ){
for(sFace = 0 ; sFace %26lt;= 12; sFace++ ){
if (shuffledCard[sSuit][sFace] == sCard ){
player[pSuit][pFace] = sSuit;
pFace++;
player[pSuit][pFace] = sFace;
pFace--;
pSuit++;
}
}
}
}
cardStart = sCard;
}
void cGame::deal(int playerHand[][2], const char *suit1[], const char *face1[])
{
int a , b;
for ( a = 0 ; a %26lt;= 4; a++ )
{
b = 0;
std::cout%26lt;%26lt;"%s"%26lt;%26lt;suit1[playerH...
b = 1;
std::cout%26lt;%26lt;"%s "%26lt;%26lt;face1[playerHand[a][b]]);
}
}
void cGame::whatHand( int playerHand [][2] )
{
int x,y;
int positFace[5], positSuit[5];
int *fPtr = positFace, *sPtr = positSuit ;
int Facepass = 0;
int Suitpass = 0 ;
int straight = 0;
for ( x = 0 ; x %26lt;= 4 ; x++ )
{
y = 1 ;
*fPtr = playerHand[x][y];
fPtr++ ;
}
for ( x = 0 ; x %26lt;= 4 ; x++ )
{
y = 0 ;
*sPtr = playerHand[x][y];
sPtr++ ;
}
for ( x = 0 ; x %26lt;= 3 ; x++ )
{
for ( y = (x + 1); y %26lt;= 4 ; y++ )
{
if ( *(positFace + x ) == *(positFace + y ) )
{
Facepass++;
}
}
}
for ( y = 0 ; y %26lt;= 3 ; y++ )
{
for (x = 0 ; x %26lt;= 3 ; x++ )
{
if ( positFace[x] %26gt; positFace[x+1] )
{
Swap(%26amp;positFace[x],%26amp;positFace[...
}
}
}
for ( y = 0; y %26lt;= 3 ; y++ )
{
if ( positFace[y] == positFace[y + 1] - 1 )
{
straight++;
}
}
for ( y = 1; y %26lt;= 4 ; y++ )
{
if ( *positSuit == *(positSuit + y ) )
{
Suitpass++;
}
}
switch ( Facepass )
{
case 1 :
std::cout%26lt;%26lt;"This poker hand contains a pair\n";
break ;
case 2 :
std::cout%26lt;%26lt;"This poker hand contains two pairs\n";
break;
case 3 :
std::cout%26lt;%26lt;"This poker hand contains three of a kind\n";
break ;
case 4:
std::cout%26lt;%26lt;"This poker hand contains a full house\n";
break ;
case 6:
std::cout%26lt;%26lt;"This poker hand contains four of a kind\n";
break ;
default :
if ( Suitpass == 4 %26amp;%26amp; straight != 4)
{
std::cout%26lt;%26lt;"This poker hand contains a flush\n";
}
if ( straight == 4 %26amp;%26amp; Suitpass != 4)
{
std::cout%26lt;%26lt;"This poker hand contains a straight\n";
}
if ( straight == 4 %26amp;%26amp; Suitpass == 4)
{
std::cout%26lt;%26lt;"This poker hand contains a straight flush\n";
}
break;
}
}
int main()
{
cPlayer thisplayer(Play#1, 1000);
thisplayer.print();
deck[4][13];
shuffle(deck, deckFace, deckSuit);
play(Play#1, deck);
deal(Play#1, suit, face);
whatHand(Play#1);
cPlayer thisplayer(Play#2, 1000);
thisplayer.print();
deck[4][13];
shuffle(deck, deckFace, deckSuit);
play(Play#2, deck);
deal(Play#2, suit, face);
whatHand(Play#2);
cPlayer thisplayer(Play#3, 1000);
thisplayer.print();
deck[4][13];
shuffle(deck, deckFace, deckSuit);
play(Play#3, deck);
deal(Play#3, suit, face);
whatHand(Play#3);
addPlayer thisplayer();
thisplayer.print();
deck[4][13];
shuffle(deck, deckFace, deckSuit);
play(playerName, deck);
deal(playerName, suit, face);
whatHand(playerName);
return 0;
}
Please help me rewrite this poker game C++ code and make it work...?
Sorry dude no time.
Reply:what error did your compiler give you?
#include %26lt;string%26gt;
#include %26lt;time.h%26gt;
using namespace std;
class cCard
{
public:
char face[13] = {'2', '3', '4', '5', '6', '7', '8', '9', 'T', 'J', 'Q', 'K', 'A'};
enum suit[4] = {"S", "H", "D", "C"};
int getSuit ();
int getFace();
void print();
};
int cCard::getSuit()
{
return suit;
}
int cCard::getFace()
{
return face;
}
void cCard::print()
{
std::cout%26lt;%26lt;face %26lt;%26lt;suit;
}
class cDeck
{
public:
void shuffle();
char Card[13][4];
void Deck;
};
void cDeck::shuffle()
{
int face, suit;
for(face = 2; face %26lt; 13; face++)
{
for(suit = 0; suit %26lt; 4; suit++)
Card[face][suit] = NULL;
}
}
void cDeck::Deck()
{
int card, suit, face;
int deck[deckSuit][deckFace];
card = 1 ;
for (suit = 0 ; suit %26lt;= deckSuit - 1 ; suit++ )
{
for (face = 0 ; face %26lt;= deckFace - 1 ; face++ )
{
deck[suit][face] = card ;
card++;
}
}
}
class cPlayer
{
public:
string cPlayer();
void printHand();
void print();
};
string cPlayer::cPlayer(string name, int stake)
{
playerName = name;
playerStake = stake;
}
void cPlayer::printHand()
{
std::cout%26lt;%26lt;Card%26lt;%26lt;"\tab"%26lt;%26lt;Card%26lt;...
}
void cPlayer::print()
{
cout%26lt;%26lt;name %26lt;%26lt;" $" %26lt;%26lt;stake %26lt;%26lt;"\n";
}
class cGame
{
public:
bool addPlayer();
void play();
void deal();
void cardQuality();
void print();
};
bool cGame::addPlayer(string playerName, int playerStake)
{
std::cout %26lt;%26lt; "Enter your name: ";
std::cin %26gt;%26gt; playerName;
std::cout %26lt;%26lt; "\nHow much money you have for the game? ";
std::cin %26gt;%26gt; playerStake;
}
void cGame::play(int player[][2] , int shuffledCard[][13])
{
int sCard, sSuit, sFace, pSuit = 0 , pFace = 0;
static int cardStart = 1;
for (sCard = cardStart ; sCard %26lt;= cardStart + 4; sCard++ ) {
for (sSuit = 0 ; sSuit %26lt;= 3; sSuit++ ){
for(sFace = 0 ; sFace %26lt;= 12; sFace++ ){
if (shuffledCard[sSuit][sFace] == sCard ){
player[pSuit][pFace] = sSuit;
pFace++;
player[pSuit][pFace] = sFace;
pFace--;
pSuit++;
}
}
}
}
cardStart = sCard;
}
void cGame::deal(int playerHand[][2], const char *suit1[], const char *face1[])
{
int a , b;
for ( a = 0 ; a %26lt;= 4; a++ )
{
b = 0;
std::cout%26lt;%26lt;"%s"%26lt;%26lt;suit1[playerH...
b = 1;
std::cout%26lt;%26lt;"%s "%26lt;%26lt;face1[playerHand[a][b]]);
}
}
void cGame::whatHand( int playerHand [][2] )
{
int x,y;
int positFace[5], positSuit[5];
int *fPtr = positFace, *sPtr = positSuit ;
int Facepass = 0;
int Suitpass = 0 ;
int straight = 0;
for ( x = 0 ; x %26lt;= 4 ; x++ )
{
y = 1 ;
*fPtr = playerHand[x][y];
fPtr++ ;
}
for ( x = 0 ; x %26lt;= 4 ; x++ )
{
y = 0 ;
*sPtr = playerHand[x][y];
sPtr++ ;
}
for ( x = 0 ; x %26lt;= 3 ; x++ )
{
for ( y = (x + 1); y %26lt;= 4 ; y++ )
{
if ( *(positFace + x ) == *(positFace + y ) )
{
Facepass++;
}
}
}
for ( y = 0 ; y %26lt;= 3 ; y++ )
{
for (x = 0 ; x %26lt;= 3 ; x++ )
{
if ( positFace[x] %26gt; positFace[x+1] )
{
Swap(%26amp;positFace[x],%26amp;positFace[...
}
}
}
for ( y = 0; y %26lt;= 3 ; y++ )
{
if ( positFace[y] == positFace[y + 1] - 1 )
{
straight++;
}
}
for ( y = 1; y %26lt;= 4 ; y++ )
{
if ( *positSuit == *(positSuit + y ) )
{
Suitpass++;
}
}
switch ( Facepass )
{
case 1 :
std::cout%26lt;%26lt;"This poker hand contains a pair\n";
break ;
case 2 :
std::cout%26lt;%26lt;"This poker hand contains two pairs\n";
break;
case 3 :
std::cout%26lt;%26lt;"This poker hand contains three of a kind\n";
break ;
case 4:
std::cout%26lt;%26lt;"This poker hand contains a full house\n";
break ;
case 6:
std::cout%26lt;%26lt;"This poker hand contains four of a kind\n";
break ;
default :
if ( Suitpass == 4 %26amp;%26amp; straight != 4)
{
std::cout%26lt;%26lt;"This poker hand contains a flush\n";
}
if ( straight == 4 %26amp;%26amp; Suitpass != 4)
{
std::cout%26lt;%26lt;"This poker hand contains a straight\n";
}
if ( straight == 4 %26amp;%26amp; Suitpass == 4)
{
std::cout%26lt;%26lt;"This poker hand contains a straight flush\n";
}
break;
}
}
int main()
{
cPlayer thisplayer(Play#1, 1000);
thisplayer.print();
deck[4][13];
shuffle(deck, deckFace, deckSuit);
play(Play#1, deck);
deal(Play#1, suit, face);
whatHand(Play#1);
cPlayer thisplayer(Play#2, 1000);
thisplayer.print();
deck[4][13];
shuffle(deck, deckFace, deckSuit);
play(Play#2, deck);
deal(Play#2, suit, face);
whatHand(Play#2);
cPlayer thisplayer(Play#3, 1000);
thisplayer.print();
deck[4][13];
shuffle(deck, deckFace, deckSuit);
play(Play#3, deck);
deal(Play#3, suit, face);
whatHand(Play#3);
addPlayer thisplayer();
thisplayer.print();
deck[4][13];
shuffle(deck, deckFace, deckSuit);
play(playerName, deck);
deal(playerName, suit, face);
whatHand(playerName);
return 0;
}
Please help me rewrite this poker game C++ code and make it work...?
Sorry dude no time.
Reply:what error did your compiler give you?
Can somebody explain to me that simple C# loop plz?
using System;
class UseDecimal {
public static void Main() {
decimal price;
decimal discount;
decimal discounted_price;
// compute discounted price
price = 19.95m;
discount = 0.15m; // discount rate is 15%
discounted_price = price - ( price * discount);
Console.WriteLine("Discounted price: $" + discounted_price);
}
}
The output from this program is shown here:
Discounted price: $16.9575
Sorry I am trying to find out how do we get $16.9575??
Thanks for explaining into details. I am learning C# and I have trouble to understand the for loop for some reason!1 I understand other loops but the (FOR) loop gives me issues.
Can somebody explain to me that simple C# loop plz?
it's self explantory if you look at the line
// compute discounted price
price = 19.95m;
discount = 0.15m; // discount rate is 15%
discounted_price = price - ( price * discount);
It sounds like to me you are having a mental block at the moment.
The best thing to do is to just take a breather away from what you are frustrated over and come back to it later. Sometimes it ends up clicking when you do that.
Also, when learning something new, try not to let your brain make it more complicated that it is. Are you taking classes or are you just reading books?
class UseDecimal {
public static void Main() {
decimal price;
decimal discount;
decimal discounted_price;
// compute discounted price
price = 19.95m;
discount = 0.15m; // discount rate is 15%
discounted_price = price - ( price * discount);
Console.WriteLine("Discounted price: $" + discounted_price);
}
}
The output from this program is shown here:
Discounted price: $16.9575
Sorry I am trying to find out how do we get $16.9575??
Thanks for explaining into details. I am learning C# and I have trouble to understand the for loop for some reason!1 I understand other loops but the (FOR) loop gives me issues.
Can somebody explain to me that simple C# loop plz?
it's self explantory if you look at the line
// compute discounted price
price = 19.95m;
discount = 0.15m; // discount rate is 15%
discounted_price = price - ( price * discount);
It sounds like to me you are having a mental block at the moment.
The best thing to do is to just take a breather away from what you are frustrated over and come back to it later. Sometimes it ends up clicking when you do that.
Also, when learning something new, try not to let your brain make it more complicated that it is. Are you taking classes or are you just reading books?
Can somebody please help me with this C++ code?
#include %26lt;iostream%26gt;
#include %26lt;string%26gt;
#include %26lt;time.h%26gt;
using namespace std;
class cCard
{
public:
char face[13] = {'2', '3', '4', '5', '6', '7', '8', '9', 'T', 'J', 'Q', 'K', 'A'};
enum suit[4] = {"S", "H", "D", "C"};
int getSuit ();
int getFace();
void print();
};
int cCard::getSuit()
{
return suit;
}
int cCard::getFace()
{
return face;
}
void cCard::print()
{
std::cout%26lt;%26lt;face %26lt;%26lt;suit;
}
class cDeck
{
public:
void shuffle();
char Card[13][4];
void Deck;
};
void cDeck::shuffle()
{
int face, suit;
for(face = 2; face %26lt; 13; face++)
{
for(suit = 0; suit %26lt; 4; suit++)
Card[face][suit] = NULL;
}
}
void cDeck::Deck()
{
int card, suit, face;
int deck[deckSuit][deckFace];
card = 1 ;
for (suit = 0 ; suit %26lt;= deckSuit - 1 ; suit++ )
{
for (face = 0 ; face %26lt;= deckFace - 1 ; face++ )
{
deck[suit][face] = card ;
card++;
}
}
}
class cPlayer
{
public:
string cPlayer();
void printHand();
void print();
};
string cPlayer::cPlayer(string name, int stake)
{
playerName = name;
playerStake = stake;
}
void cPlayer::printHand()
{
std::cout%26lt;%26lt;Card%26lt;%26lt;"\tab"%26lt;%26lt;Card%26lt;%26lt;"\tab"%26lt;%26lt;C...
}
void cPlayer::print()
{
cout%26lt;%26lt;name %26lt;%26lt;" $" %26lt;%26lt;stake %26lt;%26lt;"\n";
}
class cGame
{
public:
bool addPlayer();
void play();
void deal();
void cardQuality();
void print();
};
bool cGame::addPlayer(string playerName, int playerStake)
{
std::cout %26lt;%26lt; "Enter your name: ";
std::cin %26gt;%26gt; playerName;
std::cout %26lt;%26lt; "\nHow much money you have for the game? ";
std::cin %26gt;%26gt; playerStake;
}
void cGame::play(int player[][2] , int shuffledCard[][13])
{
int sCard, sSuit, sFace, pSuit = 0 , pFace = 0;
static int cardStart = 1;
for (sCard = cardStart ; sCard %26lt;= cardStart + 4; sCard++ ) {
for (sSuit = 0 ; sSuit %26lt;= 3; sSuit++ ){
for(sFace = 0 ; sFace %26lt;= 12; sFace++ ){
if (shuffledCard[sSuit][sFace] == sCard ){
player[pSuit][pFace] = sSuit;
pFace++;
player[pSuit][pFace] = sFace;
pFace--;
pSuit++;
}
}
}
}
cardStart = sCard;
}
void cGame::deal(int playerHand[][2], const char *suit1[], const char *face1[])
{
int a , b;
for ( a = 0 ; a %26lt;= 4; a++ )
{
b = 0;
std::cout%26lt;%26lt;"%s"%26lt;%26lt;suit1[playerHand[a][b]]...
b = 1;
std::cout%26lt;%26lt;"%s "%26lt;%26lt;face1[playerHand[a][b]]);
}
}
void cGame::whatHand( int playerHand [][2] )
{
int x,y;
int positFace[5], positSuit[5];
int *fPtr = positFace, *sPtr = positSuit ;
int Facepass = 0;
int Suitpass = 0 ;
int straight = 0;
for ( x = 0 ; x %26lt;= 4 ; x++ )
{
y = 1 ;
*fPtr = playerHand[x][y];
fPtr++ ;
}
for ( x = 0 ; x %26lt;= 4 ; x++ )
{
y = 0 ;
*sPtr = playerHand[x][y];
sPtr++ ;
}
for ( x = 0 ; x %26lt;= 3 ; x++ )
{
for ( y = (x + 1); y %26lt;= 4 ; y++ )
{
if ( *(positFace + x ) == *(positFace + y ) )
{
Facepass++;
}
}
}
for ( y = 0 ; y %26lt;= 3 ; y++ )
{
for (x = 0 ; x %26lt;= 3 ; x++ )
{
if ( positFace[x] %26gt; positFace[x+1] )
{
Swap(%26amp;positFace[x],%26amp;positFace[x+1]);
}
}
}
for ( y = 0; y %26lt;= 3 ; y++ )
{
if ( positFace[y] == positFace[y + 1] - 1 )
{
straight++;
}
}
for ( y = 1; y %26lt;= 4 ; y++ )
{
if ( *positSuit == *(positSuit + y ) )
{
Suitpass++;
}
}
switch ( Facepass )
{
case 1 :
std::cout%26lt;%26lt;"This poker hand contains a pair\n";
break ;
case 2 :
std::cout%26lt;%26lt;"This poker hand contains two pairs\n";
break;
case 3 :
std::cout%26lt;%26lt;"This poker hand contains three of a kind\n";
break ;
case 4:
std::cout%26lt;%26lt;"This poker hand contains a full house\n";
break ;
case 6:
std::cout%26lt;%26lt;"This poker hand contains four of a kind\n";
break ;
default :
if ( Suitpass == 4 %26amp;%26amp; straight != 4)
{
std::cout%26lt;%26lt;"This poker hand contains a flush\n";
}
if ( straight == 4 %26amp;%26amp; Suitpass != 4)
{
std::cout%26lt;%26lt;"This poker hand contains a straight\n";
}
if ( straight == 4 %26amp;%26amp; Suitpass == 4)
{
std::cout%26lt;%26lt;"This poker hand contains a straight flush\n";
}
break;
}
}
int main()
{
cPlayer thisplayer(Play#1, 1000);
thisplayer.print();
deck[4][13];
shuffle(deck, deckFace, deckSuit);
play(Play#1, deck);
deal(Play#1, suit, face);
whatHand(Play#1);
cPlayer thisplayer(Play#2, 1000);
thisplayer.print();
deck[4][13];
shuffle(deck, deckFace, deckSuit);
play(Play#2, deck);
deal(Play#2, suit, face);
whatHand(Play#2);
cPlayer thisplayer(Play#3, 1000);
thisplayer.print();
deck[4][13];
shuffle(deck, deckFace, deckSuit);
play(Play#3, deck);
deal(Play#3, suit, face);
whatHand(Play#3);
addPlayer thisplayer();
thisplayer.print();
deck[4][13];
shuffle(deck, deckFace, deckSuit);
play(playerName, deck);
deal(playerName, suit, face);
whatHand(playerName);
return 0;
}
Can somebody please help me with this C++ code?
this is one issue
enum suit[4] = {"S", "H", "D", "C"}; %26lt;---not an int
int cCard::getSuit()
{
return suit; %26lt;--returning an int
}
******
additional
looked further down realized your next one also returned an int when what you had was a char
Reply:what's the problem?
balsam
#include %26lt;string%26gt;
#include %26lt;time.h%26gt;
using namespace std;
class cCard
{
public:
char face[13] = {'2', '3', '4', '5', '6', '7', '8', '9', 'T', 'J', 'Q', 'K', 'A'};
enum suit[4] = {"S", "H", "D", "C"};
int getSuit ();
int getFace();
void print();
};
int cCard::getSuit()
{
return suit;
}
int cCard::getFace()
{
return face;
}
void cCard::print()
{
std::cout%26lt;%26lt;face %26lt;%26lt;suit;
}
class cDeck
{
public:
void shuffle();
char Card[13][4];
void Deck;
};
void cDeck::shuffle()
{
int face, suit;
for(face = 2; face %26lt; 13; face++)
{
for(suit = 0; suit %26lt; 4; suit++)
Card[face][suit] = NULL;
}
}
void cDeck::Deck()
{
int card, suit, face;
int deck[deckSuit][deckFace];
card = 1 ;
for (suit = 0 ; suit %26lt;= deckSuit - 1 ; suit++ )
{
for (face = 0 ; face %26lt;= deckFace - 1 ; face++ )
{
deck[suit][face] = card ;
card++;
}
}
}
class cPlayer
{
public:
string cPlayer();
void printHand();
void print();
};
string cPlayer::cPlayer(string name, int stake)
{
playerName = name;
playerStake = stake;
}
void cPlayer::printHand()
{
std::cout%26lt;%26lt;Card%26lt;%26lt;"\tab"%26lt;%26lt;Card%26lt;%26lt;"\tab"%26lt;%26lt;C...
}
void cPlayer::print()
{
cout%26lt;%26lt;name %26lt;%26lt;" $" %26lt;%26lt;stake %26lt;%26lt;"\n";
}
class cGame
{
public:
bool addPlayer();
void play();
void deal();
void cardQuality();
void print();
};
bool cGame::addPlayer(string playerName, int playerStake)
{
std::cout %26lt;%26lt; "Enter your name: ";
std::cin %26gt;%26gt; playerName;
std::cout %26lt;%26lt; "\nHow much money you have for the game? ";
std::cin %26gt;%26gt; playerStake;
}
void cGame::play(int player[][2] , int shuffledCard[][13])
{
int sCard, sSuit, sFace, pSuit = 0 , pFace = 0;
static int cardStart = 1;
for (sCard = cardStart ; sCard %26lt;= cardStart + 4; sCard++ ) {
for (sSuit = 0 ; sSuit %26lt;= 3; sSuit++ ){
for(sFace = 0 ; sFace %26lt;= 12; sFace++ ){
if (shuffledCard[sSuit][sFace] == sCard ){
player[pSuit][pFace] = sSuit;
pFace++;
player[pSuit][pFace] = sFace;
pFace--;
pSuit++;
}
}
}
}
cardStart = sCard;
}
void cGame::deal(int playerHand[][2], const char *suit1[], const char *face1[])
{
int a , b;
for ( a = 0 ; a %26lt;= 4; a++ )
{
b = 0;
std::cout%26lt;%26lt;"%s"%26lt;%26lt;suit1[playerHand[a][b]]...
b = 1;
std::cout%26lt;%26lt;"%s "%26lt;%26lt;face1[playerHand[a][b]]);
}
}
void cGame::whatHand( int playerHand [][2] )
{
int x,y;
int positFace[5], positSuit[5];
int *fPtr = positFace, *sPtr = positSuit ;
int Facepass = 0;
int Suitpass = 0 ;
int straight = 0;
for ( x = 0 ; x %26lt;= 4 ; x++ )
{
y = 1 ;
*fPtr = playerHand[x][y];
fPtr++ ;
}
for ( x = 0 ; x %26lt;= 4 ; x++ )
{
y = 0 ;
*sPtr = playerHand[x][y];
sPtr++ ;
}
for ( x = 0 ; x %26lt;= 3 ; x++ )
{
for ( y = (x + 1); y %26lt;= 4 ; y++ )
{
if ( *(positFace + x ) == *(positFace + y ) )
{
Facepass++;
}
}
}
for ( y = 0 ; y %26lt;= 3 ; y++ )
{
for (x = 0 ; x %26lt;= 3 ; x++ )
{
if ( positFace[x] %26gt; positFace[x+1] )
{
Swap(%26amp;positFace[x],%26amp;positFace[x+1]);
}
}
}
for ( y = 0; y %26lt;= 3 ; y++ )
{
if ( positFace[y] == positFace[y + 1] - 1 )
{
straight++;
}
}
for ( y = 1; y %26lt;= 4 ; y++ )
{
if ( *positSuit == *(positSuit + y ) )
{
Suitpass++;
}
}
switch ( Facepass )
{
case 1 :
std::cout%26lt;%26lt;"This poker hand contains a pair\n";
break ;
case 2 :
std::cout%26lt;%26lt;"This poker hand contains two pairs\n";
break;
case 3 :
std::cout%26lt;%26lt;"This poker hand contains three of a kind\n";
break ;
case 4:
std::cout%26lt;%26lt;"This poker hand contains a full house\n";
break ;
case 6:
std::cout%26lt;%26lt;"This poker hand contains four of a kind\n";
break ;
default :
if ( Suitpass == 4 %26amp;%26amp; straight != 4)
{
std::cout%26lt;%26lt;"This poker hand contains a flush\n";
}
if ( straight == 4 %26amp;%26amp; Suitpass != 4)
{
std::cout%26lt;%26lt;"This poker hand contains a straight\n";
}
if ( straight == 4 %26amp;%26amp; Suitpass == 4)
{
std::cout%26lt;%26lt;"This poker hand contains a straight flush\n";
}
break;
}
}
int main()
{
cPlayer thisplayer(Play#1, 1000);
thisplayer.print();
deck[4][13];
shuffle(deck, deckFace, deckSuit);
play(Play#1, deck);
deal(Play#1, suit, face);
whatHand(Play#1);
cPlayer thisplayer(Play#2, 1000);
thisplayer.print();
deck[4][13];
shuffle(deck, deckFace, deckSuit);
play(Play#2, deck);
deal(Play#2, suit, face);
whatHand(Play#2);
cPlayer thisplayer(Play#3, 1000);
thisplayer.print();
deck[4][13];
shuffle(deck, deckFace, deckSuit);
play(Play#3, deck);
deal(Play#3, suit, face);
whatHand(Play#3);
addPlayer thisplayer();
thisplayer.print();
deck[4][13];
shuffle(deck, deckFace, deckSuit);
play(playerName, deck);
deal(playerName, suit, face);
whatHand(playerName);
return 0;
}
Can somebody please help me with this C++ code?
this is one issue
enum suit[4] = {"S", "H", "D", "C"}; %26lt;---not an int
int cCard::getSuit()
{
return suit; %26lt;--returning an int
}
******
additional
looked further down realized your next one also returned an int when what you had was a char
Reply:what's the problem?
balsam
Creating assemblies for C# Console app.?
I'm a C# newbie, without any previous knowledge/experience in programming.
So I've been trying my hand at a few console apps at the moment.
I created five programs, viz. Prime numbers.cs, array_manipulation.cs, calculator.cs, factorial.cs, and Fibonacci.cs
All these files have the same namespace "Ritz".
Moreover, they are part of the same project and each of them has their own static Main function.
Now what I wanna do is create a WinForm,and place buttons on the form to launch these console apps.
Please help me out with this, I am a newbie, but obedient, and will get the hang of any sort of jargon you wanna use........
I'll post the source codes if that would help you to help me......
Thanks,
Ritz
Creating assemblies for C# Console app.?
Somewhere under Project Properties you can change your application type to a Windows Application, instead of a Console Application.
I really recommend you just create a new Windows Application project, usually a file called Program.cs is created with a special Main() function preconfigured to launch a window.
You can use the Process.Start() command to trigger your console apps to run as other processes.
So I've been trying my hand at a few console apps at the moment.
I created five programs, viz. Prime numbers.cs, array_manipulation.cs, calculator.cs, factorial.cs, and Fibonacci.cs
All these files have the same namespace "Ritz".
Moreover, they are part of the same project and each of them has their own static Main function.
Now what I wanna do is create a WinForm,and place buttons on the form to launch these console apps.
Please help me out with this, I am a newbie, but obedient, and will get the hang of any sort of jargon you wanna use........
I'll post the source codes if that would help you to help me......
Thanks,
Ritz
Creating assemblies for C# Console app.?
Somewhere under Project Properties you can change your application type to a Windows Application, instead of a Console Application.
I really recommend you just create a new Windows Application project, usually a file called Program.cs is created with a special Main() function preconfigured to launch a window.
You can use the Process.Start() command to trigger your console apps to run as other processes.
Write a C++ program that will find out the total amount of a customer's bill according to the items purchased.
Write a C++ program that will find out the total amount of a customer's bill according to the items purchased.
Create two classes: Purchased_item, Bill
The Purchased_item should be having the following data members
" item_num //for item number
note: item_num //should be static. This data member will be used to display the item number whose information is currently required from the user
" price //for per unit price
" quantity //for quantity purchased
class Bill should have two data members
" total_amount //for the total amount of bill that is to be paid
" items[5] //an array of purchased_item; should be 5 in size
class Bill should also have a member function that is used to calculate the total amount and assign it to the data member , total_amount
Your program should take input of the price and quantity of 5 items and display the total amount after calculation.
Write a C++ program that will find out the total amount of a customer's bill according to the items purchased.
its ur home work baby........so try do it by urself.
Create two classes: Purchased_item, Bill
The Purchased_item should be having the following data members
" item_num //for item number
note: item_num //should be static. This data member will be used to display the item number whose information is currently required from the user
" price //for per unit price
" quantity //for quantity purchased
class Bill should have two data members
" total_amount //for the total amount of bill that is to be paid
" items[5] //an array of purchased_item; should be 5 in size
class Bill should also have a member function that is used to calculate the total amount and assign it to the data member , total_amount
Your program should take input of the price and quantity of 5 items and display the total amount after calculation.
Write a C++ program that will find out the total amount of a customer's bill according to the items purchased.
its ur home work baby........so try do it by urself.
How can I run an exe file by C# Windows programming?
How can I run an exe file by C# Windows programming? I have problems in running an exe file by clicking the button that i made in c# windows programing, can anyone of you write the code of event handler in c# through which i can run exe file by just clicking the button,rest of the code is:
using System;
using System.Windows.Forms;
using System.Drawing;
class ButtonForm : Form {
Button MyButton = new Button();
public ButtonForm() {
Text = "Respond to a Button";
MyButton = new Button();
MyButton.Text = "Press Here";
MyButton.Location = new Point(100, 200);
// Add button event handler to list.
MyButton.Click += new EventHandler(MyButtonClick);
Controls.Add(MyButton);
}
[STAThread]
public static void Main() {
ButtonForm skel = new ButtonForm();
Application.Run(skel);
}
// Handler for MyButton.
{ Please guide me with this part.
}
}
Thank u in advance.
How can I run an exe file by C# Windows programming?
Okay, you already have a function defined, you need to go to your Form.cs file, where the EventHandler is located.
MyButton.Click += new EventHandler(MyButtonClick);
This points to the MyButtonClick function.
**************************************...
Now you need to add:
using System.Diagnostics;
Then create a process:
Process TheProcessYouNamed;
private void MyButtonClick(object sender, EventArgs e)
{
TheProcessYouNamed = Process.Start("EXEToRun.exe");
TheProcessYouNamed.CloseMainWindow();
}
using System;
using System.Windows.Forms;
using System.Drawing;
class ButtonForm : Form {
Button MyButton = new Button();
public ButtonForm() {
Text = "Respond to a Button";
MyButton = new Button();
MyButton.Text = "Press Here";
MyButton.Location = new Point(100, 200);
// Add button event handler to list.
MyButton.Click += new EventHandler(MyButtonClick);
Controls.Add(MyButton);
}
[STAThread]
public static void Main() {
ButtonForm skel = new ButtonForm();
Application.Run(skel);
}
// Handler for MyButton.
{ Please guide me with this part.
}
}
Thank u in advance.
How can I run an exe file by C# Windows programming?
Okay, you already have a function defined, you need to go to your Form.cs file, where the EventHandler is located.
MyButton.Click += new EventHandler(MyButtonClick);
This points to the MyButtonClick function.
**************************************...
Now you need to add:
using System.Diagnostics;
Then create a process:
Process TheProcessYouNamed;
private void MyButtonClick(object sender, EventArgs e)
{
TheProcessYouNamed = Process.Start("EXEToRun.exe");
TheProcessYouNamed.CloseMainWindow();
}
Subscribe to:
Posts (Atom)