overloading ostream op in card class



 DEVELOP > c-Plus-Plus > overloading ostream op in card class

LINK TO THIS PAGE  


rating :  0   |  0


  Page 1 of 1

1

 
Topic: DEVELOP > c-Plus-Plus
User: "sahm"
Date: 14 Dec 2004 12:21:07 PM
Object: overloading ostream op in card class
hi,
i created a function
ostream& operator<<(ostream& out, vector<Card>& deck)
{
int i = 0;
for (int s = 1; s <= 4; s++)
{
for (int r = 1; r <= 13; r++, i++)
{
deck[i].setSuit(s);
deck[i].setRank(r);
deck[i].printCard(out);
}
out << endl;
system("pause");
out << endl;
}
return out;
}
//that will print out the ordered deck of cards, i need to create a
function that will overload ostream operator, and that will print out
the cards in the hand in random order(ranges 5 to 15)...
void fillHand(ostream& out, vector<Card>& hand, vector<Card>& deck2)
{
for(unsigned int i = 0; i < hand.size(); i++)
{
int random;
random = randNum(0, 51);
if(deck2[random].isPicked())
{
deck2[random].printCard(out);
cout << endl;
int last = hand.size() - 1;
hand.push_back(hand[last]);
for(int i = last; i > deck2[random].isPicked();
i--)
{
hand[last] = hand[last - 1];
}
}
else
{
hand[i] = deck2[random];
deck2[random].setPicked(true);
hand[i].printCard(out);
cout << endl;
}
}
}
//this worked, but it's not giving me random cards...pls i need help
.

User: "David Harmon"

Title: Re: overloading ostream op in card class 14 Dec 2004 02:24:38 PM
On 14 Dec 2004 10:21:07 -0800 in comp.lang.c++, "sahm" <abigael_b@yahoo.com> wrote,

//this worked, but it's not giving me random cards...pls i need help

#include <algorithm>
std::random_shuffle(deck.begin(), deck.end());
.


  Page 1 of 1

1

 


Related Articles
Nokia N95 Hoodies Sunglasses Nokia N93 Nokia N70 Sony memory card Mobile Phones
display from video card visual c++
PSP PS2 PS3 Nokia N95 Hoodies Sunglasses Nokia N93 Nokia N70 Sonymemory card(www.fashion-sky.com)
How to read/write raw bytes from a flash card in C++?
How to simulate REAL card shuffling?
C++ Reference Card?
C++ Source Code for Baccarat Card Game?
Make a software & interfacing it with access control card reader
Quick reference card
Hoodies Sunglasses Nokia N93 Nokia N70 Sony memory card Mobile Phonesetc
Nokia N95 Hoodies Sunglasses Nokia N93 Nokia N70 Sony memory card Mobile Phones
Re: Getting graphic card info
Nokia N95 Hoodies Sunglasses Nokia N93 Nokia N70 Sony memory card Mobile Phones
can a hardware programmable card do this?
Program Solaris driver for parallel port SmartMedia card reader?
 

NEWER

pg.1232     pg.940     pg.716     pg.544     pg.412     pg.311     pg.234     pg.175     pg.130     pg.96     pg.70     pg.50     pg.35     pg.24     pg.16     pg.10     pg.6     pg.3     pg.1

OLDER