⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 blackjack.cs

📁 this is a good book for the visual c#
💻 CS
📖 第 1 页 / 共 3 页
字号:
// Fig. 21.15: Blackjack.cs
// Blackjack game that uses the Blackjack Web service.

using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;   
using System.Net;

namespace Game 
{
   // game that uses Blackjack Web Service
   public class Blackjack : System.Windows.Forms.Form
   {
      private System.Windows.Forms.PictureBox pictureBox1;
      private System.Windows.Forms.PictureBox pictureBox2;
      private System.Windows.Forms.PictureBox pictureBox3;
      private System.Windows.Forms.PictureBox pictureBox4;
      private System.Windows.Forms.PictureBox pictureBox5;
      private System.Windows.Forms.PictureBox pictureBox6;
      private System.Windows.Forms.PictureBox pictureBox7;
      private System.Windows.Forms.PictureBox pictureBox8;
      private System.Windows.Forms.PictureBox pictureBox9;
      private System.Windows.Forms.PictureBox pictureBox10;
      private System.Windows.Forms.PictureBox pictureBox11;
      private System.Windows.Forms.PictureBox pictureBox12;
      private System.Windows.Forms.PictureBox pictureBox13;
      private System.Windows.Forms.PictureBox pictureBox14;
      private System.Windows.Forms.PictureBox pictureBox15;
      private System.Windows.Forms.PictureBox pictureBox16;
      private System.Windows.Forms.PictureBox pictureBox17;
      private System.Windows.Forms.PictureBox pictureBox18;
      private System.Windows.Forms.PictureBox pictureBox19;
      private System.Windows.Forms.PictureBox pictureBox20;
      private System.Windows.Forms.PictureBox pictureBox21;
      private System.Windows.Forms.PictureBox pictureBox22;

      private System.Windows.Forms.Button dealButton;
      private System.Windows.Forms.Button hitButton;
      private System.Windows.Forms.Button stayButton;
   
      private System.ComponentModel.Container components = null;

      private localhost.BlackjackService dealer;
      private string dealersCards, playersCards;
      private ArrayList cardBoxes;
      private int playerCard, dealerCard;

      // labels displaying game status, dealer and player
      private System.Windows.Forms.Label dealerLabel;
      private System.Windows.Forms.Label playerLabel;
      private System.Windows.Forms.Label statusLabel;

      public enum GameStatus : 
         int { PUSH, LOSE, WIN, BLACKJACK };

      public Blackjack()
      {
         InitializeComponent();

         dealer = new localhost.BlackjackService();

         // allow session state
         dealer.CookieContainer = new CookieContainer();

         cardBoxes = new ArrayList();

         // put PictureBoxes into cardBoxes
         cardBoxes.Add( pictureBox1 );
         cardBoxes.Add( pictureBox2 );
         cardBoxes.Add( pictureBox3 );
         cardBoxes.Add( pictureBox4 );
         cardBoxes.Add( pictureBox5 );
         cardBoxes.Add( pictureBox6 );
         cardBoxes.Add( pictureBox7 );
         cardBoxes.Add( pictureBox8 );
         cardBoxes.Add( pictureBox9 );
         cardBoxes.Add( pictureBox10 );
         cardBoxes.Add( pictureBox11 );
         cardBoxes.Add( pictureBox12 );
         cardBoxes.Add( pictureBox13 );
         cardBoxes.Add( pictureBox14 );
         cardBoxes.Add( pictureBox15 );
         cardBoxes.Add( pictureBox16 );
         cardBoxes.Add( pictureBox17 );
         cardBoxes.Add( pictureBox18 );
         cardBoxes.Add( pictureBox19 );
         cardBoxes.Add( pictureBox20 );
         cardBoxes.Add( pictureBox21 );
         cardBoxes.Add( pictureBox22 );

      } // end method Blackjack

      #region Windows Form Designer generated code
      /// <summary>
      /// Required method for Designer support - do not modify
      /// the contents of this method with the code editor.
      /// </summary>
      private void InitializeComponent()
      {
         this.hitButton = new System.Windows.Forms.Button();
         this.pictureBox3 = new System.Windows.Forms.PictureBox();
         this.pictureBox2 = new System.Windows.Forms.PictureBox();
         this.pictureBox1 = new System.Windows.Forms.PictureBox();
         this.pictureBox7 = new System.Windows.Forms.PictureBox();
         this.pictureBox6 = new System.Windows.Forms.PictureBox();
         this.pictureBox5 = new System.Windows.Forms.PictureBox();
         this.pictureBox4 = new System.Windows.Forms.PictureBox();
         this.pictureBox9 = new System.Windows.Forms.PictureBox();
         this.pictureBox8 = new System.Windows.Forms.PictureBox();
         this.pictureBox12 = new System.Windows.Forms.PictureBox();
         this.pictureBox13 = new System.Windows.Forms.PictureBox();
         this.pictureBox10 = new System.Windows.Forms.PictureBox();
         this.pictureBox11 = new System.Windows.Forms.PictureBox();
         this.pictureBox16 = new System.Windows.Forms.PictureBox();
         this.pictureBox17 = new System.Windows.Forms.PictureBox();
         this.pictureBox14 = new System.Windows.Forms.PictureBox();
         this.pictureBox15 = new System.Windows.Forms.PictureBox();
         this.dealButton = new System.Windows.Forms.Button();
         this.pictureBox18 = new System.Windows.Forms.PictureBox();
         this.pictureBox19 = new System.Windows.Forms.PictureBox();
         this.pictureBox21 = new System.Windows.Forms.PictureBox();
         this.pictureBox20 = new System.Windows.Forms.PictureBox();
         this.pictureBox22 = new System.Windows.Forms.PictureBox();
         this.stayButton = new System.Windows.Forms.Button();
         this.statusLabel = new System.Windows.Forms.Label();
         this.dealerLabel = new System.Windows.Forms.Label();
         this.playerLabel = new System.Windows.Forms.Label();
         this.SuspendLayout();
         // 
         // hitButton
         // 
         this.hitButton.BackColor = System.Drawing.Color.Green;
         this.hitButton.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
         this.hitButton.ForeColor = System.Drawing.Color.White;
         this.hitButton.Location = new System.Drawing.Point(560, 112);
         this.hitButton.Name = "hitButton";
         this.hitButton.Size = new System.Drawing.Size(112, 56);
         this.hitButton.TabIndex = 2;
         this.hitButton.Text = "Hit";
         this.hitButton.Click += new System.EventHandler(this.hitButton_Click);
         // 
         // pictureBox3
         // 
         this.pictureBox3.BackColor = System.Drawing.Color.Green;
         this.pictureBox3.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D;
         this.pictureBox3.Location = new System.Drawing.Point(192, 56);
         this.pictureBox3.Name = "pictureBox3";
         this.pictureBox3.Size = new System.Drawing.Size(70, 90);
         this.pictureBox3.TabIndex = 0;
         this.pictureBox3.TabStop = false;
         // 
         // pictureBox2
         // 
         this.pictureBox2.BackColor = System.Drawing.Color.Green;
         this.pictureBox2.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D;
         this.pictureBox2.Location = new System.Drawing.Point(104, 56);
         this.pictureBox2.Name = "pictureBox2";
         this.pictureBox2.Size = new System.Drawing.Size(70, 90);
         this.pictureBox2.TabIndex = 0;
         this.pictureBox2.TabStop = false;
         // 
         // pictureBox1
         // 
         this.pictureBox1.BackColor = System.Drawing.Color.Green;
         this.pictureBox1.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D;
         this.pictureBox1.Location = new System.Drawing.Point(16, 56);
         this.pictureBox1.Name = "pictureBox1";
         this.pictureBox1.Size = new System.Drawing.Size(70, 90);
         this.pictureBox1.TabIndex = 0;
         this.pictureBox1.TabStop = false;
         // 
         // pictureBox7
         // 
         this.pictureBox7.BackColor = System.Drawing.Color.Green;
         this.pictureBox7.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D;
         this.pictureBox7.Location = new System.Drawing.Point(104, 168);
         this.pictureBox7.Name = "pictureBox7";
         this.pictureBox7.Size = new System.Drawing.Size(70, 90);
         this.pictureBox7.TabIndex = 0;
         this.pictureBox7.TabStop = false;
         // 
         // pictureBox6
         // 
         this.pictureBox6.BackColor = System.Drawing.Color.Green;
         this.pictureBox6.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D;
         this.pictureBox6.Location = new System.Drawing.Point(456, 56);
         this.pictureBox6.Name = "pictureBox6";
         this.pictureBox6.Size = new System.Drawing.Size(70, 90);
         this.pictureBox6.TabIndex = 0;
         this.pictureBox6.TabStop = false;
         // 
         // pictureBox5
         // 
         this.pictureBox5.BackColor = System.Drawing.Color.Green;
         this.pictureBox5.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D;
         this.pictureBox5.Location = new System.Drawing.Point(368, 56);
         this.pictureBox5.Name = "pictureBox5";
         this.pictureBox5.Size = new System.Drawing.Size(70, 90);
         this.pictureBox5.TabIndex = 0;
         this.pictureBox5.TabStop = false;
         // 
         // pictureBox4
         // 
         this.pictureBox4.BackColor = System.Drawing.Color.Green;
         this.pictureBox4.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D;
         this.pictureBox4.Location = new System.Drawing.Point(280, 56);
         this.pictureBox4.Name = "pictureBox4";
         this.pictureBox4.Size = new System.Drawing.Size(70, 90);
         this.pictureBox4.TabIndex = 0;
         this.pictureBox4.TabStop = false;
         // 
         // pictureBox9
         // 
         this.pictureBox9.BackColor = System.Drawing.Color.Green;
         this.pictureBox9.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D;
         this.pictureBox9.Location = new System.Drawing.Point(192, 168);
         this.pictureBox9.Name = "pictureBox9";
         this.pictureBox9.Size = new System.Drawing.Size(70, 90);
         this.pictureBox9.TabIndex = 0;
         this.pictureBox9.TabStop = false;
         // 
         // pictureBox8
         // 
         this.pictureBox8.BackColor = System.Drawing.Color.Green;
         this.pictureBox8.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D;
         this.pictureBox8.Location = new System.Drawing.Point(16, 168);
         this.pictureBox8.Name = "pictureBox8";
         this.pictureBox8.Size = new System.Drawing.Size(70, 90);
         this.pictureBox8.TabIndex = 0;
         this.pictureBox8.TabStop = false;
         // 
         // pictureBox12

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -