/// <summary> /// Runs unit tests for the Android class. /// </summary> static void TestAndroid() { Hand h = new Hand(); Console.WriteLine("Tests for the Android class:\n"); Android c3po = new Android("c3po", h); //Console.WriteLine("Output Window with 'c3po' as banner should have popped up."); //Not applicable in Blackjack3 Deck d = new Deck(); //Test getCard() and showHand(). c3po.getsCard(d.deal()); c3po.getsCard(d.deal()); Console.WriteLine("Current Hand after having been dealt two cards: \n"); h = c3po.showHand(); Console.WriteLine(h.ToString()); //Tests outcomeOfRound() Console.WriteLine("Test a win by pressing enter."); Console.ReadLine(); c3po.outcomeOfRound(Outcome.Win); Console.WriteLine("Sucsess."); //Tests wantsCard() Console.WriteLine("Test wantsCard() by pressing enter."); Console.ReadLine(); c3po.wantsCard(); Console.WriteLine("Success.\n"); }
static void Main() { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); //Application.Run(new OutputForm()); //Instead, we're suing OutputForm as a passive output form... //that each player constructs on thier own. // WRITE ME: CONSTRUCT MODEL OBJECTS // CONSTRUCT CONTROLLER // CONSTRUCT VIEWS // REGISTER VIEWS WITH CONTROLLER // START THE SYSTEM //Models are created, and later passed on to the entities that own them (dealer/players). Deck d = new Deck(); Hand humanHand = new Hand(); Hand houseHand = new Hand(); //Players! Player housePlayer = new Android("House", houseHand); List<Player> guestPlayers = new List<Player>(); guestPlayers.Add(new Human("You", humanHand)); //Controller (The Dealer)! Dealer dealer = new Dealer(guestPlayers, housePlayer, d); //Construct views! HumansHandForm humanForm = new HumansHandForm(dealer.newRound, dealer.dealACardToHuman, dealer.playerDecidedToHold, humanHand, houseHand); Scoreboard scoreboard = new Scoreboard(humanHand, dealer.numberOfWins, dealer.numberOfRounds, dealer.gameStatus); HouseHandForm houseForm = new HouseHandForm(houseHand); //Display views! humanForm.Show(); scoreboard.Show(); houseForm.Show(); //Register the methods that update the forms. dealer.registerOb(humanForm.showhand); dealer.registerObHouseHandOnly(houseForm.updateHand); dealer.registerOb(scoreboard.updateScore); dealer.registerOb(scoreboard.updateWins); dealer.registerOb(scoreboard.updateRounds); dealer.registerOb(scoreboard.updateStatus); //The HumansHandForm will serve as our main view. Application.Run(humanForm); //We will conculde our program with a cute little message box before exiting. MessageBox.Show("Thanks for playing! Click to exit.", "Exit"); }
/// <summary> /// Runs unit tests for the Dealer class. /// </summary> static void TestDealer() { Hand h1 = new Hand(); Hand h2 = new Hand(); Deck d = new Deck(); Console.WriteLine("Tests for the Dealer Class"); List<Player> guests = new List<Player>(); Human George = new Human("George", h1); Android r2d2 = new Android("r2d2", h2); guests.Add(George); Dealer dealer = new Dealer(guests, r2d2, d); Console.WriteLine("Test number of Rounds: " + dealer.numberOfRounds() + "\n(Should display 0)"); Console.WriteLine("Test number of wins: " + dealer.numberOfWins() + "\n(Should display 0)"); Console.WriteLine("Test game status: " + dealer.gameStatus() + "\n(Should display status)"); Console.WriteLine("This concludes all of the unit test that don't require use of the forms."); Console.WriteLine("If this point has been reached, then all tests have been completed sucsessfully."); Console.WriteLine("Please press enter when you are ready to quit."); }