Code Newbie
News     Forums     Search     Members     Sign Up    

My Code Newbie
Username

Password

Articles/Snippets
ASP Classic
ASP.NET
C
C#
C++
HTML / CSS
Java
Javascript
Linux / BSD
Perl
PHP
Python
Ruby
SQL
VB 6
VB.NET

C.N. Friends
  Planet Rome

Link to Us!
Code Newbie
  Code Newbie
    forums

Go Back   Code Forums > Application and Web Development > Standard C, C++

Reply
 
LinkBack Thread Tools Display Modes
Old 05-10-2004, 11:19 PM   #61 (permalink)
dirs
Registered User
 
Join Date: May 2004
Posts: 40
dirs is on a distinguished road
Thanks a lot....!
Yesterday I read your tutorial on Operator overlaoding and that was quite good. When I am finished with this assignment I would like to learn more from you . You have very good command in C++ and you have
been quite helpful and patient.
Ofcourse I would let you know how it went with the assignment.
dirs is offline   Reply With Quote
Old 05-11-2004, 12:04 AM   #62 (permalink)
Valmont
[code][/code] enforcer
 
Valmont's Avatar
 
Join Date: Mar 2003
Location: Netherlands
Posts: 1,544
Valmont is on a distinguished road
Quote:
Yesterday I read your tutorial on Operator overlaoding...
Aaaah! Then you are able to find out how our overloaded << works then huh? .

I wonder at what time (wich country are you in?) you downloaded the final. Because I uploaded an update a few times; I fixed a few annoying little things and I fixed a subtle (!) 50% modifier bug (for black jack situations).
__________________
Valmont is offline   Reply With Quote
Old 05-11-2004, 09:42 AM   #63 (permalink)
Valmont
[code][/code] enforcer
 
Valmont's Avatar
 
Join Date: Mar 2003
Location: Netherlands
Posts: 1,544
Valmont is on a distinguished road
ZIP file Updated.
Has now a "smar" dealer. Uses statistics instead of standing at 16.
__________________
Valmont is offline   Reply With Quote
Old 05-11-2004, 10:10 AM   #64 (permalink)
dirs
Registered User
 
Join Date: May 2004
Posts: 40
dirs is on a distinguished road
Quote:
Originally posted by Valmont
ZIP file Updated.
Has now a "smar" dealer. Uses statistics instead of standing at 16.
Shall i download it from same place?
dirs is offline   Reply With Quote
Old 05-11-2004, 10:36 AM   #65 (permalink)
dirs
Registered User
 
Join Date: May 2004
Posts: 40
dirs is on a distinguished road
Quote:
Originally posted by dirs
Shall i download it from same place?
That was better! But have you removed some print outputs?
Also when for Hit or stand if we press anything else than key 1 or 0 then things go wrong. so we could have a test where we check if key is 0 or 1 and if not just print that press key 1 or key 0 instead!

Last edited by dirs; 05-11-2004 at 11:02 AM.
dirs is offline   Reply With Quote
Old 05-11-2004, 12:34 PM   #66 (permalink)
dirs
Registered User
 
Join Date: May 2004
Posts: 40
dirs is on a distinguished road
Quote:
Originally posted by dirs
That was better! But have you removed some print outputs?
Also when for Hit or stand if we press anything else than key 1 or 0 then things go wrong. so we could have a test where we check if key is 0 or 1 and if not just print that press key 1 or key 0 instead!
A hand consist of two cards in Blackjack game so when u give card
void BlackJack::GiveCard(Player& plyr)
{
plyr.Hand.push_back(*m_Deck.getDeck().begin());

m_Deck.RemoveTopCard();
}

can we use loop to give 2 cards instead?
dirs is offline   Reply With Quote
Old 05-11-2004, 02:20 PM   #67 (permalink)
Valmont
[code][/code] enforcer
 
Valmont's Avatar
 
Join Date: Mar 2003
Location: Netherlands
Posts: 1,544
Valmont is on a distinguished road
Quote:
But have you removed some print outputs?
Not really. I just outcommented them.
Find the outcommented code:
Code:
void BlackJack::Shuffle()
{
	//pre shuffle
	/* m_Deck.Show(cout);
	cout<<endl;  */
	m_Deck.Shuffle();	
	//Show the deck. The traditional way. Using a simple loop:
/*	for(int i = 0; i<m_Deck.getDeck().size(); ++i)
	{
		cout<<m_Deck.getDeck()[ i ]<<endl;		
	}
	cout<<endl<<endl; */

	//An elegant way below, using the overloaded operator and a 
	//Nice demonstration of the vector::copy() method (rarely used
	//because people seem not to know how to use it).
	/*  m_Deck.Show(cout);  */
}
Quote:
Also when for Hit or stand if we press anything else than key 1 or 0 then things go wrong. so we could have a test where we check if key is 0 or 1 and if not just print that press key 1 or key 0 instead!
The fact that things go wrong if you press a non-numeric key has been fixed in the version you can download below. So pressing a character (or a string) is fixed. But ONLY in the method where you're asked for your wager (that one was buggy too).
There is another one left to fix: When pressing a character (or a string in general) when computer asks you if you stand or hit. I did that on purpose!
Try it yourself. It is basic routine wich one should learn.
You also asked to skip for feedback on wich key(s) to press. What do you want? That strangers should guess wich keys are allowed to press?
Think again.
Quote:
A hand consist of two cards in Blackjack game so when u give card
void BlackJack::GiveCard(Player& plyr)
{
plyr.Hand.push_back(*m_Deck.getDeck().begin());

m_Deck.RemoveTopCard();
}

can we use loop to give 2 cards instead?
Then you might not have understood how the method works: Just code twice:
Code:
GiveCard(thePlayer)
m_Deck.RemoveTopCard();
GiveCard(thePlayer)
m_Deck.RemoveTopCard();
You do that in the Go() method. And guess what...
Even I implemented the casino rules (like we play it here in our country), the game still works. The stability is really of a mature level !

In many casinos you can double your wager when you received your first card, if is a 9, 10 or Ace. But then you will receive one card ONLY. Better hope it is something good. You won't get anymore than two.
But your wish for dealing two cards in the first turn eliminates that option. And vice versa, if I implement this rule ( I will becase I like it), then dealing two card for one player in the first turn won't go anymore.

You can download the updated code below. It has even a smarter dealer!
The previous one wasn't good with aces :p.
blackjackvc6final
__________________
Valmont is offline   Reply With Quote
Old 05-12-2004, 05:59 AM   #68 (permalink)
cheawick
Regular Contributor
 
cheawick's Avatar
 
Join Date: Dec 2003
Location: Mary Esther, FL
Posts: 189
cheawick is on a distinguished road
Hey Valmont,
I was going to private message you this, but I though other newbies as myself might benefit from this question.
Just because a program is written in VC++ and not in another generic C++ compiler, does this mean that there will be incapatibilities?
cheawick is offline   Reply With Quote
Old 05-12-2004, 07:21 AM   #69 (permalink)
Valmont
[code][/code] enforcer
 
Valmont's Avatar
 
Join Date: Mar 2003
Location: Netherlands
Posts: 1,544
Valmont is on a distinguished road
There might be incompatibilities. But not there will.
To solve such issues (and much more) there is something called "ANSI/ISO" standard. That is a guide wich proposes a vast amount of C++ language definitions. Compiler builders try to abide by the "rules" in it.
The MSVC6 compiler compiler is pretty old actually (more than 5 years) so it doesn't comply with certain rules anymore. Nevertheless it is still usable tho.
Quote:
.... another generic C++, ... compiler
There is no such thing as that.
C++ compilers are ment for C/C++. C++ doesn't know (according to ANSI) standards about Windows or Linux or UNIX or OS2 or MAC-OS or Intel CPU's or AMD CPU's, etcetera. So a compiler doesn't know about that either.
Nevertheless, many companies will add compiler options so it fits the needs of the company (their products) better. For example, the #pragma macro is used to set compiler options. Microsoft options may be different then Borland options. So officially, this macro isn't supported by the standard, but there "unofficial official" reccomendations though.
It all depends upon how much effort is done to build one that meets the standards as much as possible.
__________________
Valmont is offline   Reply With Quote
Old 05-13-2004, 06:07 AM   #70 (permalink)
cheawick
Regular Contributor
 
cheawick's Avatar
 
Join Date: Dec 2003
Location: Mary Esther, FL
Posts: 189
cheawick is on a distinguished road
ANSI I understand the concept of, but what is ISO?
cheawick is offline   Reply With Quote
Old 05-13-2004, 03:27 PM   #71 (permalink)
Valmont
[code][/code] enforcer
 
Valmont's Avatar
 
Join Date: Mar 2003
Location: Netherlands
Posts: 1,544
Valmont is on a distinguished road
ANSI = core
ISO = containers, algorithms, iostreams etc.

That's an informal wrap up by me. I forgot the exact definitions. It's been years ago when I looked up the exact roles of the both comittees.
__________________
Valmont is offline   Reply With Quote
Old 05-14-2004, 06:29 AM   #72 (permalink)
cheawick
Regular Contributor
 
cheawick's Avatar
 
Join Date: Dec 2003
Location: Mary Esther, FL
Posts: 189
cheawick is on a distinguished road
Hmm. Still not sure I follow ISO. Is it like a hardware recognition tool? As ANSI may be viewed as software conventions? Or am I way off kilter here?
cheawick is offline   Reply With Quote
Old 05-14-2004, 07:06 AM   #73 (permalink)
Valmont
[code][/code] enforcer
 
Valmont's Avatar
 
Join Date: Mar 2003
Location: Netherlands
Posts: 1,544
Valmont is on a distinguished road
Don't you know what containers are? Or iterators? Or algorithms?

But nevermind, I couln't have been more innaccurate. No time. But here is bit more detailed explanation.

ISO is the International Standard Organisation, whilst ANSI is the representative for the USA. Not for the government but for the US organisations, academics etc, industry, and agencies of the USA.

Whilst ISO is represented by each nation (that wishes to be part of it).

Now, decisions are taken by a voting process. One individual member of the ANSI staff, votes for (or against) an ISO proposal. After that, the ISO commitee itself will vote. In reality, none of the ISO votes were ever in contrast with an ANSI vote.
In fact, the technical commitee of the ISO consists almost solely out of the tech. com. of the ANSI.

If you want a copy (on paper) with the deinitions of ISO C++ then go to: http://www.ansi.org
Choose: Catalogs/Standards Information, then "ANSI-ISO-IEC Online Catalog". Search for "14882".
About $100 (USD).
Or in PDF format:
http://webstore.ansi.org/ansidocstore/default.asp
Wich is about $15.
__________________

Last edited by Valmont; 05-14-2004 at 07:46 AM.
Valmont is offline   Reply With Quote
Old 05-14-2004, 04:55 PM   #74 (permalink)
cheawick
Regular Contributor
 
cheawick's Avatar
 
Join Date: Dec 2003
Location: Mary Esther, FL
Posts: 189
cheawick is on a distinguished road
Looking back on it I do know what those are. I've been working 12 to 14 hour shifts this week and seem to be missing a few cerebral cylinders lately.
I figure I'll squeak out a few more brain farts before the weekend is out before normal function returns.:p
cheawick is offline   Reply With Quote
Old 05-17-2004, 11:53 AM   #75 (permalink)
dirs
Registered User
 
Join Date: May 2004
Posts: 40
dirs is on a distinguished road
Hi Valmont ,
Could u pls explain what is this fn doing?
void BlackJack::reset_istream(istream & is)
{
char ch;
// Reset the state.
is.clear();
// Remove all characters until we find a newline or EOF.
ch = is.get();
while ((ch != '\n')&&(ch != EOF))
ch = is.get();
is.clear();
}
dirs is offline   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
to put data methods inside class or not? sde Java 2 05-25-2004 05:09 PM
pointer to function with class? Kportertx Standard C, C++ 5 04-11-2003 06:12 AM
class theory sde PHP 2 01-11-2003 01:48 PM


All times are GMT -8. The time now is 01:34 PM.


Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.0.0 RC8





Copyright © 2000-2008, Milano Interactive
Web Hosting provided by Portal 360 Web Hosting