That is what it started out as.
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
This is what I have came up with so far.
using System;
using System.Collections.Generic;
using System.Text;
namespace Lab1
{
public class Program
{
static Random rgen = newRandom();
public static void Main(string[] args)
{
string name = "";
double cash = 0.0;
int more = "yes";
{
string betAmount = 0;
do
{
if (betAmount > cash)
{
Console.WriteLine("You do not have enough cash for that bet.");
Console.WriteLine("Cash:" & cash);
}
}
while (betAmount > cash);
Console.WriteLine("Press Enter to draw a card.");
player = rgen.Next(2, 15);
DisplayCard(player);
Console.WriteLine("Press Enter to see dealer's card");
player = rgen.Next(2, 15);
DisplayCard(dealer);
bool playerwon = Evaluate(player, dealer);
if (playerWon)
{
Console.WriteLine("name(), you win!");
cash = cash + betAmount;
}
{
if (playerLost)
Console.WriteLine("name(), you loose");
cash = cash - betAmount;
}
if (cash > 0)
{
Console.WriteLine("You have", cash, "cash in hand");
int more = ("play again? (yes/no");
}
if (cash < 0)
{
Console.WriteLine("You are out of cash");
more = "no";
}
while (more = "yes") ;
Console.WriteLine("Thanks for playing");
}
}
}
public static void displayCard(int card)
{if(card == 14)
Console.WriteLine("Ace");
else if (card == 13)
Console.WriteLine("King");
else if (card == 12)
Console.WriteLine("Queen");
else if (card ==11)
Console.WriteLine("Jack");
else if (card <= 2 AND card <= 10)
Console.WriteLine("card");
else
console.WriteLine("error: card is not valid");
}
public static bool Evaluate(int player, int dealer);
if (player > dealer)
Console.ReadLine("true");
else if (dealer > player)
Console.ReadLine("false");
else if
Console.WriteLine("Tie. We go to WAR!");
Console.WriteLine("Press Enter to draw a card");
player = rgen.Next(2,15);
displayCard(player)
Console.WriteLine("Press enter to see the dealer's card."),
player = rgen.Next(2,15);
displayCard(dealer)
Evaluate(player, dealer);
}
}
The second method it says the void shouldn't be there and the third method it says the bool shouldn't be the and at the end it says end of file expected. Not sure how to fix this.