2021년 목표설정

이미지
기본적으로 작년에 달성하지 못한 것들을 하려고 생각중인데..코로나가 언제까지 이어질지, 한국이나 북해도는 갈 수 있을지..자격증은 응시 가능할지..여러가지가 불확실하다. 2021년은 무엇보다 정신적인 부분과 경제적인 부분에 중점을 두고 조금 더 치열하게 지내보고 싶다. 일본나이로도 30대 마지막 해, 이제 불혹에 접어드는 나이..복잡하지만 심플하게. 육체적목표 : 트라이에슬론 스탠다드 도전하기 정신적 : 자격증2개 도전 + 자체개발 서비스 론칭 가족적 : 가정의 평화를 유지하기 경제적 : 외식과 유흥비를 줄이고 부수입을 늘려서 결과적으로 저축하기 사회적 : 목표세미나를 포함해서 민단과 개인인맥의 활성화와 교류를 촉진하기

C# 예제 세번째


어디에 들이대기도 민망한 야구게임 ㅋㅋ
숫자 맞추는 소스도 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;
  }
 }
}

댓글

이 블로그의 인기 게시물

성공적인 소셜커머스를 위한 10단계 전략

[C# & LINQ] 랜덤으로 데이터를 한 개 추출하는 방법

[메모] PostgreSQL에서 Insert 하는 경우 자동채번 PK가 중복에러 나는 경우