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
Old 05-17-2004, 03:14 PM   #76 (permalink)
Valmont
[code][/code] enforcer
 
Valmont's Avatar
 
Join Date: Mar 2003
Location: Netherlands
Posts: 1,544
Valmont is on a distinguished road
Read the first post in this link wich someone recently posted:
http://codenewbie.com/forum/t1931.html
Now, the code you are asking about, is another way to prevent skipping user input. It clears the stream, so you code won't skip user input if the stream is "polluted".

If you also read my reply, you will encounter another and more correct way to deal with it. THAT is the code wich I implemented in the update below:
http://home.tiscali.nl/~valmont/cpp/...ckvc6final.zip
Besides that update (fix), there is another fix for the dealer's decision algorithm.
__________________

Last edited by Valmont; 05-17-2004 at 04:26 PM.
Valmont is offline   Reply With Quote
Old 05-18-2004, 09:06 AM   #77 (permalink)
Valmont
[code][/code] enforcer
 
Valmont's Avatar
 
Join Date: Mar 2003
Location: Netherlands
Posts: 1,544
Valmont is on a distinguished road
Updated to some decent code (efficiency and removal of double code).
__________________
Valmont is offline   Reply With Quote
Old 05-18-2004, 12:03 PM   #78 (permalink)
dirs
Registered User
 
Join Date: May 2004
Posts: 40
dirs is on a distinguished road
Hi Valmont!
I have submitted my assignment today! Thanks a lot for the help.
Would try to do more and more C++ programming! Do u know about good tutorials on internet on c++?
dirs is offline   Reply With Quote
Old 05-18-2004, 12:08 PM   #79 (permalink)
Valmont
[code][/code] enforcer
 
Valmont's Avatar
 
Join Date: Mar 2003
Location: Netherlands
Posts: 1,544
Valmont is on a distinguished road
Nope.
But this one is a nice try:
http://www.cplusplus.com/doc/tutorial
__________________
Valmont is offline   Reply With Quote
Old 05-18-2004, 12:10 PM   #80 (permalink)
Valmont
[code][/code] enforcer
 
Valmont's Avatar
 
Join Date: Mar 2003
Location: Netherlands
Posts: 1,544
Valmont is on a distinguished road
Quote:
Originally posted by dirs
Hi Valmont!
I have submitted my assignment today! Thanks a lot for the help.
Would try to do more and more C++ programming! Do u know about good tutorials on internet on c++?
Did you download the latest code?
The one with this in it:
Code:
bool BlackJack::CalcDealerDecision()
{
	int good = 0;	
	int space = (21 - theDealer.m_nPoints);

	if(space > 0)
	{
		for(unsigned i=0; i < m_Deck.getDeck().size(); ++i)
		{
			int cardvalue = static_cast<int>(m_Deck[i].getValue());
			if(cardvalue > 10 )
			{
				if(cardvalue < 14)
					cardvalue = 10;
				else
					cardvalue = 1;
			}
			if((cardvalue % 14) <= (space) )
				good++;
		}
		cout<<(good / static_cast<float>(m_Deck.getDeck().size())) * 100<<"%"<<endl;
		if(good / static_cast<float>(m_Deck.getDeck().size()) > 0.5)
			return true;
	}
	return false; 
}
__________________
Valmont is offline   Reply With Quote
Old 05-20-2004, 04:47 AM   #81 (permalink)
dirs
Registered User
 
Join Date: May 2004
Posts: 40
dirs is on a distinguished road
I submitted the assignment before you sent the new code!!!
Anyways Thanks again..
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 04:09 PM
pointer to function with class? Kportertx Standard C, C++ 5 04-11-2003 05:12 AM
class theory sde PHP 2 01-11-2003 12:48 PM


All times are GMT -8. The time now is 06:39 AM.


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