Click here to Skip to main content
15,888,816 members
Please Sign up or sign in to vote.
1.25/5 (8 votes)
See more:
Can anyone help me convert this pseudo code into C# for VB 2005 ?
VB
Start Main( )
	Get name of player
	Get cash (starting cash amout)
	Set more = "yes"
	Start Loop
		Set betAmount = 0;
		Start Loop
Get betAmount
If( betAmount > cash )
	Display "You do not have enough cash for that bet amount."
Display "Cash: " & cash
			End If
While( betAmount > cash ), continue looping
		Display "Press Enter to draw a card."
		Generate a random number from 2 to 14 and place in player variable
		Call DisplayCard( player )
		Display "Press Enter to see the dealer’s card."
		Create a random number between 2 and 14 and place in dealer variable
		Call DisplayCard( dealer )
		Call Evaluate( player, dealer ) that returns a boolean (true if player wins)
		If player wins then
			Display name & ", you win!"
			Increase cash by the betAmount
		Otherwise
			Display name & ", you lose"
			Decrease cash by the betAmount
		End If
		If cash > 0 then
Display "You have " & cash & " cash in hand."
			Get more with prompt "Play again? (yes/no): "
		Otherwise
			Display "You are out of cash."
			Set more = "no"
		End If
	While more = "yes", continue looping
	Display "Thanks for playing."
Stop


Start DisplayCard( card as integer )
	If card = 14 then
		Display "Ace"
	Otherwise if card = 13 then
		Display "King"
	Otherwise if card = 12 then
		Display "Queen"
	Otherwise if card = 11 then
		Display "Jack"
	Otherwise if card >= 2 AND card <= 10 then
		Display card
	Otherwise
		Display "Error: " & card & "is not valid."
	End If
Stop


Start Evaluate( player, dealer )
	If player > dealer then
		Return true
	Otherwise if dealer > player then
		Return false
	Otherwise
		Display "Tie.  We go to WAR!"
		Display "Press Enter to draw a card."
		Generate a random number between 2 and 14 and place in player variable
		Call DisplayCard( player )
		Display "Press Enter to see the dealer’s card."
		Create a random number between 2 and 14 and place in dealer variable
		Call DisplayCard( dealer )
		Return result of Evaluate( player, dealer ) –recursion will continue until someone wins
	End If	
Stop
Posted
Updated 5-Sep-10 8:00am
v2
Comments
Sandeep Mewara 5-Sep-10 14:00pm    
What have you tried so far? Where are you stuck up right now, tell us and might be someone can help.

You gotto start and try yourself first!
AnthonyBocc 5-Sep-10 14:27pm    
Hey Sandeep....The problem is I had the code written in VB 05' in full....Saved it to my thumb drive and someone stole my backpack. I have class in less than 45 mins and no way I can get the code written in full by then. I just need to know if someone can write code fast or has a program similar already written ? Thanks to all
Toli Cuturicu 5-Sep-10 15:16pm    
If you have an urgency, CodeProject is not the place to post a question.
Peter_in_2780 5-Sep-10 19:48pm    
Maybe you'll consider a backup strategy next time.
dan!sh 6-Sep-10 6:33am    
You can provide the stealth as an excuse for now and show whatever possibly can be done in the remaining time frame. Maybe write down the core logic stripping off the aesthetics. Good luck!

No, nobody can help you with that. If you have pseudo-code, you already have the solution defined. It should be a simple matter to actually write the code - certainly easier than if you have to write it without a design.

I think it's either time for you to cowboy-up and be a real programmer, or hire someone to do it for you.
 
Share this answer
 
Comments
Sergey Alexandrovich Kryukov 10-Dec-10 14:45pm    
John Simmons just gave you a wonderful idea. If you follow his advice you will win!
Thank you.
The answer is: no, nobody can, because "C# for VB 2005" is oxymoron.
This is final answer!

Seriously, do you seriously want to put this simple and boring work on any stranger volunteer, just to compensate your sloppiness in the past (if I correctly understood your comment)? God help you! Better learn some programming, including C#. VB along will not help you much in your career.
 
Share this answer
 
v2
Comments
Espen Harlinn 26-Feb-11 11:01am    
Good reply - a 5
Sergey Alexandrovich Kryukov 26-Feb-11 19:43pm    
Thank you, Espen.
It's wonderful that my "denial" answer was accepted well.
--SA

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900