mirror of
https://github.com/coding-horror/basic-computer-games.git
synced 2025-12-22 23:26:40 -08:00
Simplify War (C#) folder structure
This commit is contained in:
35
94_War/csharp/War/Program.cs
Normal file
35
94_War/csharp/War/Program.cs
Normal file
@@ -0,0 +1,35 @@
|
||||
namespace War
|
||||
{
|
||||
class Program
|
||||
{
|
||||
static void Main(string[] args)
|
||||
{
|
||||
var ui = new UserInterface();
|
||||
ui.WriteIntro();
|
||||
|
||||
var deck = new Deck();
|
||||
deck.Shuffle();
|
||||
|
||||
int yourScore = 0;
|
||||
int computersScore = 0;
|
||||
bool usedAllCards = true;
|
||||
|
||||
for (int i = 0; i < Deck.deckSize; i += 2)
|
||||
{
|
||||
// Play the next hand.
|
||||
var yourCard = deck.GetCard(i);
|
||||
var computersCard = deck.GetCard(i + 1);
|
||||
|
||||
ui.WriteAResult(yourCard, computersCard, ref computersScore, ref yourScore);
|
||||
|
||||
if (!ui.AskAQuestion("DO YOU WANT TO CONTINUE? "))
|
||||
{
|
||||
usedAllCards = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
ui.WriteClosingRemarks(usedAllCards, yourScore, computersScore);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user