数学测试 游戏

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

namespace KarelCS
{
 /// <summary>
 /// Summary description for Form1.
 /// </summary>
 public class Form1 : System.Windows.Forms.Form
 {
  /// <summary>
  /// Required designer variable.
  /// </summary>
  private System.ComponentModel.Container components = null;
  internal System.Windows.Forms.Button Button3;
  internal System.Windows.Forms.Button Button2;
  internal System.Windows.Forms.Button Button1;
  private static Landscaper [] allRobots = new Landscaper[1];
  private  const int East = 0;
  private  const int South = 1;
  private  const int West = 2;
  private  const int North = 3;
  public Form1()
  {
   //
   // Required for Windows Form Designer support
   //
   InitializeComponent();

   //
   // TODO: Add any constructor code after InitializeComponent call
   //
   World.setDelay(20);
   World.readWorld("garden.txt");
   task();
  }

  /// <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.Button3 = new System.Windows.Forms.Button();
            this.Button2 = new System.Windows.Forms.Button();
            this.Button1 = new System.Windows.Forms.Button();
            this.SuspendLayout();
            //
            // Button3
            //
            this.Button3.Location = new System.Drawing.Point(29, 86);
            this.Button3.Name = "Button3";
            this.Button3.Size = new System.Drawing.Size(90, 25);
            this.Button3.TabIndex = 5;
            this.Button3.Text = "Reverse";
            this.Button3.Click += new System.EventHandler(this.Button3_Click);
            //
            // Button2
            //
            this.Button2.Location = new System.Drawing.Point(29, 52);
            this.Button2.Name = "Button2";
            this.Button2.Size = new System.Drawing.Size(90, 24);
            this.Button2.TabIndex = 4;
            this.Button2.Text = "Left";
            this.Button2.Click += new System.EventHandler(this.Button2_Click);
            //
            // Button1
            //
            this.Button1.Location = new System.Drawing.Point(29, 17);
            this.Button1.Name = "Button1";
            this.Button1.Size = new System.Drawing.Size(90, 25);
            this.Button1.TabIndex = 3;
            this.Button1.Text = "Move";
            this.Button1.Click += new System.EventHandler(this.Button1_Click);
            //
            // Form1
            //
            this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
            this.ClientSize = new System.Drawing.Size(292, 266);
            this.Controls.Add(this.Button3);
            this.Controls.Add(this.Button2);
            this.Controls.Add(this.Button1);
            this.Name = "Form1";
            this.Text = "Karel CS Robot Demo";
            this.Load += new System.EventHandler(this.Form1_Load);
            this.ResumeLayout(false);

  }
  #endregion

  /// <summary>
  /// The main entry point for the application.
  /// </summary>
  [STAThread]
  static void Main()
  {
   Application.Run(new Form1());
  }

  static void task()
  {
            //Landscaper Carol = new Landscaper(1, 5, North, 7);
            //Landscaper Joe = new Landscaper(5, 2, East ,7);
            //Landscaper George = new Landscaper(8, 6, South, 7);
   Landscaper Jane = new Landscaper(4, 9, West, 7);
            //allRobots[1] = Carol;
            //allRobots[2] = Joe;
            //allRobots[3] = George;
   allRobots[0] = Jane;
            //Carol.doEl();
            //Joe.doEl();
            //George.doEl();
   Jane.doEl();
  }

  private void Button1_Click(object sender, System.EventArgs e)
  {
   foreach ( myRobot r in allRobots)
    r.move();
  }

  private void Button2_Click(object sender, System.EventArgs e)
  {
   foreach ( myRobot r in allRobots)
    r.turnLeft();
  }

  private void Button3_Click(object sender, System.EventArgs e)
  {
   foreach ( myRobot r in allRobots)
    r.reverse();
  }

        private void Form1_Load(object sender, EventArgs e)
        {

        }
 }
}

posted @ 2012-04-17 22:01  |▍花舞花落泪 ╮  阅读(145)  评论(0编辑  收藏  举报