Click here to Skip to main content
15,886,199 members
Articles / Programming Languages / C#

Towers of Hanoi Puzzle Simulation

Rate me:
Please Sign up or sign in to vote.
2.59/5 (14 votes)
11 Jul 2006CPOL2 min read 68.5K   1.6K   18  
The article describes a recursive solution for the famous puzzle of the towers of Hanoi
namespace HanoiTowers
{
    partial class frmMain
    {
        /// <summary>
        /// Required designer variable.
        /// </summary>
        private System.ComponentModel.IContainer components = null;

        /// <summary>
        /// Clean up any resources being used.
        /// </summary>
        /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
        protected override void Dispose(bool disposing)
        {
            if (disposing && (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()
        {
            System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(frmMain));
            this.btnStart = new System.Windows.Forms.Button();
            this.label1 = new System.Windows.Forms.Label();
            this.numericUpDown1 = new System.Windows.Forms.NumericUpDown();
            this.panel1 = new System.Windows.Forms.Panel();
            this.lblDestination = new System.Windows.Forms.Label();
            this.lblIntermediate = new System.Windows.Forms.Label();
            this.pnlSource = new System.Windows.Forms.Panel();
            this.pnlDestination = new System.Windows.Forms.Panel();
            this.pnlIntermediate = new System.Windows.Forms.Panel();
            this.lbl2 = new System.Windows.Forms.Label();
            this.label2 = new System.Windows.Forms.Label();
            ((System.ComponentModel.ISupportInitialize)(this.numericUpDown1)).BeginInit();
            this.panel1.SuspendLayout();
            this.SuspendLayout();
            // 
            // btnStart
            // 
            this.btnStart.Location = new System.Drawing.Point(813, 480);
            this.btnStart.Name = "btnStart";
            this.btnStart.Size = new System.Drawing.Size(57, 29);
            this.btnStart.TabIndex = 0;
            this.btnStart.Text = "Start";
            this.btnStart.UseVisualStyleBackColor = true;
            this.btnStart.Click += new System.EventHandler(this.button1_Click);
            // 
            // label1
            // 
            this.label1.AutoSize = true;
            this.label1.Location = new System.Drawing.Point(115, 409);
            this.label1.Name = "label1";
            this.label1.Size = new System.Drawing.Size(40, 13);
            this.label1.TabIndex = 1;
            this.label1.Text = "Source";
            // 
            // numericUpDown1
            // 
            this.numericUpDown1.Location = new System.Drawing.Point(123, 486);
            this.numericUpDown1.Maximum = new decimal(new int[] {
            10,
            0,
            0,
            0});
            this.numericUpDown1.Minimum = new decimal(new int[] {
            1,
            0,
            0,
            0});
            this.numericUpDown1.Name = "numericUpDown1";
            this.numericUpDown1.Size = new System.Drawing.Size(58, 20);
            this.numericUpDown1.TabIndex = 2;
            this.numericUpDown1.TextAlign = System.Windows.Forms.HorizontalAlignment.Center;
            this.numericUpDown1.Value = new decimal(new int[] {
            4,
            0,
            0,
            0});
            this.numericUpDown1.ValueChanged += new System.EventHandler(this.numericUpDown1_ValueChanged);
            // 
            // panel1
            // 
            this.panel1.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D;
            this.panel1.Controls.Add(this.lblDestination);
            this.panel1.Controls.Add(this.lblIntermediate);
            this.panel1.Controls.Add(this.pnlSource);
            this.panel1.Controls.Add(this.pnlDestination);
            this.panel1.Controls.Add(this.pnlIntermediate);
            this.panel1.Controls.Add(this.label1);
            this.panel1.Location = new System.Drawing.Point(18, 35);
            this.panel1.Name = "panel1";
            this.panel1.Size = new System.Drawing.Size(852, 439);
            this.panel1.TabIndex = 3;
            // 
            // lblDestination
            // 
            this.lblDestination.AutoSize = true;
            this.lblDestination.Location = new System.Drawing.Point(672, 409);
            this.lblDestination.Name = "lblDestination";
            this.lblDestination.Size = new System.Drawing.Size(61, 13);
            this.lblDestination.TabIndex = 5;
            this.lblDestination.Text = "Destination";
            // 
            // lblIntermediate
            // 
            this.lblIntermediate.AutoSize = true;
            this.lblIntermediate.Location = new System.Drawing.Point(379, 409);
            this.lblIntermediate.Name = "lblIntermediate";
            this.lblIntermediate.Size = new System.Drawing.Size(69, 13);
            this.lblIntermediate.TabIndex = 4;
            this.lblIntermediate.Text = "Intermediate";
            // 
            // pnlSource
            // 
            this.pnlSource.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
            this.pnlSource.Location = new System.Drawing.Point(28, 25);
            this.pnlSource.Name = "pnlSource";
            this.pnlSource.Size = new System.Drawing.Size(248, 381);
            this.pnlSource.TabIndex = 1;
            this.pnlSource.TabStop = true;
            this.pnlSource.Tag = "1";
            this.pnlSource.Paint += new System.Windows.Forms.PaintEventHandler(this.pnl_Paint);
            // 
            // pnlDestination
            // 
            this.pnlDestination.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
            this.pnlDestination.Location = new System.Drawing.Point(572, 25);
            this.pnlDestination.Name = "pnlDestination";
            this.pnlDestination.Size = new System.Drawing.Size(248, 381);
            this.pnlDestination.TabIndex = 3;
            this.pnlDestination.Tag = "3";
            this.pnlDestination.Paint += new System.Windows.Forms.PaintEventHandler(this.pnl_Paint);
            // 
            // pnlIntermediate
            // 
            this.pnlIntermediate.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
            this.pnlIntermediate.Location = new System.Drawing.Point(299, 25);
            this.pnlIntermediate.Name = "pnlIntermediate";
            this.pnlIntermediate.Size = new System.Drawing.Size(248, 381);
            this.pnlIntermediate.TabIndex = 2;
            this.pnlIntermediate.Tag = "2";
            this.pnlIntermediate.Paint += new System.Windows.Forms.PaintEventHandler(this.pnl_Paint);
            // 
            // lbl2
            // 
            this.lbl2.AutoSize = true;
            this.lbl2.Location = new System.Drawing.Point(15, 488);
            this.lbl2.Name = "lbl2";
            this.lbl2.Size = new System.Drawing.Size(93, 13);
            this.lbl2.TabIndex = 4;
            this.lbl2.Text = "Number of plates:";
            // 
            // label2
            // 
            this.label2.AutoSize = true;
            this.label2.Location = new System.Drawing.Point(370, 496);
            this.label2.Name = "label2";
            this.label2.Size = new System.Drawing.Size(35, 13);
            this.label2.TabIndex = 5;
            this.label2.Text = "label2";
            // 
            // frmMain
            // 
            this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
            this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
            this.ClientSize = new System.Drawing.Size(892, 566);
            this.Controls.Add(this.label2);
            this.Controls.Add(this.lbl2);
            this.Controls.Add(this.panel1);
            this.Controls.Add(this.numericUpDown1);
            this.Controls.Add(this.btnStart);
            this.DoubleBuffered = true;
            this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.Fixed3D;
            this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
            this.Name = "frmMain";
            this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
            this.Text = "Towers of Hanoi";
            ((System.ComponentModel.ISupportInitialize)(this.numericUpDown1)).EndInit();
            this.panel1.ResumeLayout(false);
            this.panel1.PerformLayout();
            this.ResumeLayout(false);
            this.PerformLayout();

        }

        #endregion

        private System.Windows.Forms.Button btnStart;
        private System.Windows.Forms.Label label1;
        private System.Windows.Forms.NumericUpDown numericUpDown1;
        private System.Windows.Forms.Panel panel1;
        private System.Windows.Forms.Panel pnlDestination;
        private System.Windows.Forms.Panel pnlIntermediate;
        private System.Windows.Forms.Panel pnlSource;
        private System.Windows.Forms.Label lbl2;
        private System.Windows.Forms.Label lblDestination;
        private System.Windows.Forms.Label lblIntermediate;
        private System.Windows.Forms.Label label2;
    }
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Software Developer (Senior)
Egypt Egypt

Amr is an iOS developer living in Cairo/Egypt.

Works now as Lead Software Engineer at ITWorx.

Main interests : iPhone/iPad/Mac app development.

Others :
Windows,GDI+,SqlServer, ASP.Net,Custom controls and others.

Academics:
BSc Computer and Information Sciences June 2006.

Certifications:
MCSD C#.Net
MCTS:SQL Server 2005

Blog: here

Comments and Discussions