어디에 들이대기도 민망한 야구게임 ㅋㅋ숫자 맞추는 소스도 is~else if 남발하고 ㅋㅋ이상하게 \n 이 먹지 않아서 지저분하게 출력이 되었다..ㅡㅜ사용 tool : Microsoft Visual Studio .NET 2003사용 언어 : C#[ Source ]using System;using System.Drawing;using System.Collections;using System.ComponentModel;using System.Windows.Forms;using System.Data;
namespace lovelydai_ex3
{
/// <summary>
/// Summary description for Form1.
/// </summary>
public class Form1 : System.Windows.Forms.Form
{
private System.Windows.Forms.Label label1;
private System.Windows.Forms.Label label2;
private System.Windows.Forms.Label label3;
private System.Windows.Forms.TextBox textBox1;
private System.Windows.Forms.TextBox textBox2;
private System.Windows.Forms.TextBox textBox3;
private System.Windows.Forms.Button button1;
private System.Windows.Forms.GroupBox groupBox1;
private System.Windows.Forms.TextBox textBox4;
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.Container components = null;
// 세 가지 수를 입력할 수 있게 변수로 지정
// 원래는 Random 으로 해야 하지만 귀찮으니까..^^;;
int FirstNum = 7, SecondNum = 1, ThirdNum = 3;
// 스트라이크, 볼, 아웃을 check 할 변수를 선언
int Strike = 0, Ball = 0, Out = 0;
public Form1()
{
//
// Required for Windows Form Designer support
//
InitializeComponent();
//
// TODO: Add any constructor code after InitializeComponent call
//
}
/// <summary>
/// Clean up any resources being used.
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if (components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}
#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.label1 = new System.Windows.Forms.Label();
this.label2 = new System.Windows.Forms.Label();
this.label3 = new System.Windows.Forms.Label();
this.textBox1 = new System.Windows.Forms.TextBox();
this.textBox2 = new System.Windows.Forms.TextBox();
this.textBox3 = new System.Windows.Forms.TextBox();
this.button1 = new System.Windows.Forms.Button();
this.groupBox1 = new System.Windows.Forms.GroupBox();
this.textBox4 = new System.Windows.Forms.TextBox();
this.groupBox1.SuspendLayout();
this.SuspendLayout();
//
// label1
//
this.label1.Font = new System.Drawing.Font("DotumChe", 9.75F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(129)));
this.label1.Location = new System.Drawing.Point(8, 16);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(56, 16);
this.label1.TabIndex = 0;
this.label1.Text = "1번타자";
//
// label2
//
this.label2.Font = new System.Drawing.Font("DotumChe", 9.75F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(129)));
this.label2.Location = new System.Drawing.Point(8, 72);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(56, 16);
this.label2.TabIndex = 1;
this.label2.Text = "2번타자";
//
// label3
//
this.label3.Font = new System.Drawing.Font("DotumChe", 9.75F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(129)));
this.label3.Location = new System.Drawing.Point(8, 128);
this.label3.Name = "label3";
this.label3.Size = new System.Drawing.Size(56, 16);
this.label3.TabIndex = 2;
this.label3.Text = "3번타자";
//
// textBox1
//
this.textBox1.Location = new System.Drawing.Point(72, 16);
this.textBox1.Name = "textBox1";
this.textBox1.Size = new System.Drawing.Size(88, 21);
this.textBox1.TabIndex = 3;
this.textBox1.Text = "";
//
// textBox2
//
this.textBox2.Location = new System.Drawing.Point(72, 72);
this.textBox2.Name = "textBox2";
this.textBox2.Size = new System.Drawing.Size(88, 21);
this.textBox2.TabIndex = 4;
this.textBox2.Text = "";
//
// textBox3
//
this.textBox3.Location = new System.Drawing.Point(72, 128);
this.textBox3.Name = "textBox3";
this.textBox3.Size = new System.Drawing.Size(88, 21);
this.textBox3.TabIndex = 5;
this.textBox3.Text = "";
//
// button1
//
this.button1.BackColor = System.Drawing.SystemColors.Desktop;
this.button1.Cursor = System.Windows.Forms.Cursors.Hand;
this.button1.Font = new System.Drawing.Font("DotumChe", 11.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(129)));
this.button1.ForeColor = System.Drawing.SystemColors.ControlLightLight;
this.button1.Location = new System.Drawing.Point(48, 184);
this.button1.Name = "button1";
this.button1.Size = new System.Drawing.Size(320, 32);
this.button1.TabIndex = 6;
this.button1.Text = "[ Play Ball~!! ]";
this.button1.Click += new System.EventHandler(this.button1_Click);
//
// groupBox1
//
this.groupBox1.Controls.Add(this.textBox4);
this.groupBox1.Location = new System.Drawing.Point(192, 16);
this.groupBox1.Name = "groupBox1";
this.groupBox1.Size = new System.Drawing.Size(200, 136);
this.groupBox1.TabIndex = 7;
this.groupBox1.TabStop = false;
this.groupBox1.Text = "결과";
//
// textBox4
//
this.textBox4.AutoSize = false;
this.textBox4.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.textBox4.Location = new System.Drawing.Point(8, 24);
this.textBox4.Multiline = true;
this.textBox4.Name = "textBox4";
this.textBox4.Size = new System.Drawing.Size(184, 104);
this.textBox4.TabIndex = 0;
this.textBox4.Text = "";
//
// Form1
//
this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
this.ClientSize = new System.Drawing.Size(424, 237);
this.Controls.Add(this.groupBox1);
this.Controls.Add(this.button1);
this.Controls.Add(this.textBox3);
this.Controls.Add(this.textBox2);
this.Controls.Add(this.textBox1);
this.Controls.Add(this.label3);
this.Controls.Add(this.label2);
this.Controls.Add(this.label1);
this.Name = "Form1";
this.Text = "Simple BaseBall Game";
this.groupBox1.ResumeLayout(false);
this.ResumeLayout(false);
}
#endregion
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
Application.Run(new Form1());
}
private void button1_Click(object sender, System.EventArgs e)
{
if ( FirstNum == Convert.ToInt16(textBox1.Text))
{
Strike = Strike + 1;
}
else if ( SecondNum == Convert.ToInt16(textBox1.Text))
{
Ball = Ball + 1;
}
else if ( ThirdNum == Convert.ToInt16(textBox1.Text))
{
Ball = Ball + 1;
}
else
{
Out = Out + 1;
}
if ( SecondNum == Convert.ToInt16(textBox2.Text))
{
Strike = Strike + 1;
}
else if ( FirstNum == Convert.ToInt16(textBox2.Text))
{
Ball = Ball + 1;
}
else if ( ThirdNum == Convert.ToInt16(textBox2.Text))
{
Ball = Ball + 1;
}
else
{
Out = Out + 1;
}
if ( ThirdNum == Convert.ToInt16(textBox3.Text))
{
Strike = Strike + 1;
}
else if ( SecondNum == Convert.ToInt16(textBox3.Text))
{
Ball = Ball + 1;
}
else if ( FirstNum == Convert.ToInt16(textBox3.Text))
{
Ball = Ball + 1;
}
else
{
Out = Out + 1;
}
textBox4.Text = "이번 회의 결과는\r\n"+Convert.ToString(Strike)+"스트라이크\r\n"+Ball.ToString()+"볼\r\n"+Out.ToString()+"아웃\r\n"+"입니다.";
Strike=0;
Ball=0;
Out = 0;
}
}
}
댓글
댓글 쓰기