Change Output

Hello, I want to ask some question...
how to hidden output, change output into "*"(Any words would turn into "*"),
but the meaning of * is not lost.
example:

1
2
for(int a = 0; a < 52; a++)
printf("%s\n", deck[a]);


example:
OUTPUT
Ace Spade
3 Spade
S Diamond
King Heart
10 Club
.
.
.

this will be
OUTPUT
*
*
*
*
*
*
*
*

Computer know the first * is Ace Spade but player doesn't know the means.

Essentially, all of this for hide output so player doesn't know the card.
Last edited on
I don't understand anything x(

I guess you want to hide the cards from the player through asterisk. Well is it hard enough to print *******? And for the user input, remember that the cards are represented as char array or pointer so basically you just need an integer to use an index.
I'd use a class personally. Something like this:

1
2
3
4
5
6
7
8
class CARD {
     private:
      std::string value;
     public:
      char What_Player_Sees;
     public:
       std::string Get_Value() { return value; } /*For your program to see the card*/
};
This is what if statements are for. If the user is to see what the card is, print the card name. Otherwise print an asterisk.

Personally, I'd make a procedure that does the job of printing a hand, and takes as argument whether or not to display all the cards in the hand (as appropriate).

Hope this helps.
try to use getch function, here's some simple example of what you need:
http://codewall.blogspot.com/2010/12/c-password-validation.html
Last edited on
Er, you've missed the point...
computergeek has something right... to actually make this viable... you might want to link two row matrix variable that holds special values for the cards

1
2
3
4
5
6
7
8
9
class CARD { // class keyword used to define a new class
	private:
		std::string value;
                int cards_id[12][3]; // the 12 is for the 0-12//13 value of the cards and suits is the 0-3 etc etc
	public:
		char What_Player_Sees;
	public:
		std::string Get_Value() { return value; }
};
Last edited on
I disagree. Don't mix separate concepts.

A "card" class should only be interested in being a card. Not in variations of how it is to be displayed.

When the program using the card class wishes to display the card, ask the class to display itself.
When the program using the card class wishes to display asterisks, then do that.

For example, in my blackjack game (see the Blackjack thread in the lounge http://www.cplusplus.com/forum/lounge/2783/), I check to see whether or not the dealer's hand is in play or revealed, and the dealer's first card is either displayed or the words "Hole Card". This is all in the routine that displays the players' hands.

The card should know how to display itself. Not how to not display itself.

Hope this helps.
Topic archived. No new replies allowed.