Added tutorial 6
This commit is contained in:
Generated
+75
-60
@@ -30,105 +30,120 @@ namespace Duck_Simulator
|
||||
private void InitializeComponent()
|
||||
{
|
||||
this.groupBox1 = new System.Windows.Forms.GroupBox();
|
||||
this.checkBox1 = new System.Windows.Forms.CheckBox();
|
||||
this.checkBox2 = new System.Windows.Forms.CheckBox();
|
||||
this.checkBox3 = new System.Windows.Forms.CheckBox();
|
||||
this.checkBox4 = new System.Windows.Forms.CheckBox();
|
||||
this.radioButton1 = new System.Windows.Forms.RadioButton();
|
||||
this.button1 = new System.Windows.Forms.Button();
|
||||
this.button2 = new System.Windows.Forms.Button();
|
||||
this.button3 = new System.Windows.Forms.Button();
|
||||
this.radioButton2 = new System.Windows.Forms.RadioButton();
|
||||
this.radioButton3 = new System.Windows.Forms.RadioButton();
|
||||
this.radioButton4 = new System.Windows.Forms.RadioButton();
|
||||
this.groupBox1.SuspendLayout();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// groupBox1
|
||||
//
|
||||
this.groupBox1.Controls.Add(this.checkBox4);
|
||||
this.groupBox1.Controls.Add(this.checkBox3);
|
||||
this.groupBox1.Controls.Add(this.checkBox2);
|
||||
this.groupBox1.Controls.Add(this.checkBox1);
|
||||
this.groupBox1.Location = new System.Drawing.Point(12, 12);
|
||||
this.groupBox1.Controls.Add(this.radioButton1);
|
||||
this.groupBox1.Controls.Add(this.radioButton2);
|
||||
this.groupBox1.Controls.Add(this.radioButton3);
|
||||
this.groupBox1.Controls.Add(this.radioButton4);
|
||||
this.groupBox1.Location = new System.Drawing.Point(6, 6);
|
||||
this.groupBox1.Margin = new System.Windows.Forms.Padding(2);
|
||||
this.groupBox1.Name = "groupBox1";
|
||||
this.groupBox1.Size = new System.Drawing.Size(644, 911);
|
||||
this.groupBox1.Padding = new System.Windows.Forms.Padding(2);
|
||||
this.groupBox1.Size = new System.Drawing.Size(322, 474);
|
||||
this.groupBox1.TabIndex = 0;
|
||||
this.groupBox1.TabStop = false;
|
||||
this.groupBox1.Text = "Duck Selector";
|
||||
//
|
||||
// checkBox1
|
||||
// radioButton1
|
||||
//
|
||||
this.checkBox1.AutoSize = true;
|
||||
this.checkBox1.Location = new System.Drawing.Point(39, 42);
|
||||
this.checkBox1.Name = "checkBox1";
|
||||
this.checkBox1.Size = new System.Drawing.Size(170, 29);
|
||||
this.checkBox1.TabIndex = 0;
|
||||
this.checkBox1.Text = "Mallard Duck";
|
||||
this.checkBox1.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// checkBox2
|
||||
//
|
||||
this.checkBox2.AutoSize = true;
|
||||
this.checkBox2.Location = new System.Drawing.Point(39, 77);
|
||||
this.checkBox2.Name = "checkBox2";
|
||||
this.checkBox2.Size = new System.Drawing.Size(186, 29);
|
||||
this.checkBox2.TabIndex = 1;
|
||||
this.checkBox2.Text = "Redhead Duck";
|
||||
this.checkBox2.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// checkBox3
|
||||
//
|
||||
this.checkBox3.AutoSize = true;
|
||||
this.checkBox3.Location = new System.Drawing.Point(39, 112);
|
||||
this.checkBox3.Name = "checkBox3";
|
||||
this.checkBox3.Size = new System.Drawing.Size(180, 29);
|
||||
this.checkBox3.TabIndex = 2;
|
||||
this.checkBox3.Text = "Rubber Ducky";
|
||||
this.checkBox3.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// checkBox4
|
||||
//
|
||||
this.checkBox4.AutoSize = true;
|
||||
this.checkBox4.Location = new System.Drawing.Point(39, 147);
|
||||
this.checkBox4.Name = "checkBox4";
|
||||
this.checkBox4.Size = new System.Drawing.Size(160, 29);
|
||||
this.checkBox4.TabIndex = 3;
|
||||
this.checkBox4.Text = "Decoy Duck";
|
||||
this.checkBox4.UseVisualStyleBackColor = true;
|
||||
this.radioButton1.AutoSize = true;
|
||||
this.radioButton1.Location = new System.Drawing.Point(6, 20);
|
||||
this.radioButton1.Name = "radioButton1";
|
||||
this.radioButton1.Size = new System.Drawing.Size(88, 17);
|
||||
this.radioButton1.TabIndex = 4;
|
||||
this.radioButton1.TabStop = true;
|
||||
this.radioButton1.Text = "Mallard Duck";
|
||||
this.radioButton1.UseVisualStyleBackColor = true;
|
||||
this.radioButton1.CheckedChanged += new System.EventHandler(this.radioButton1_CheckedChanged);
|
||||
//
|
||||
// button1
|
||||
//
|
||||
this.button1.Location = new System.Drawing.Point(682, 36);
|
||||
this.button1.Location = new System.Drawing.Point(341, 19);
|
||||
this.button1.Margin = new System.Windows.Forms.Padding(2);
|
||||
this.button1.Name = "button1";
|
||||
this.button1.Size = new System.Drawing.Size(134, 47);
|
||||
this.button1.Size = new System.Drawing.Size(67, 24);
|
||||
this.button1.TabIndex = 4;
|
||||
this.button1.Text = "Quack";
|
||||
this.button1.UseVisualStyleBackColor = true;
|
||||
this.button1.Click += new System.EventHandler(this.button1_Click);
|
||||
//
|
||||
// button2
|
||||
//
|
||||
this.button2.Location = new System.Drawing.Point(682, 106);
|
||||
this.button2.Location = new System.Drawing.Point(341, 55);
|
||||
this.button2.Margin = new System.Windows.Forms.Padding(2);
|
||||
this.button2.Name = "button2";
|
||||
this.button2.Size = new System.Drawing.Size(134, 47);
|
||||
this.button2.Size = new System.Drawing.Size(67, 24);
|
||||
this.button2.TabIndex = 5;
|
||||
this.button2.Text = "Fly";
|
||||
this.button2.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// button3
|
||||
//
|
||||
this.button3.Location = new System.Drawing.Point(682, 179);
|
||||
this.button3.Location = new System.Drawing.Point(341, 93);
|
||||
this.button3.Margin = new System.Windows.Forms.Padding(2);
|
||||
this.button3.Name = "button3";
|
||||
this.button3.Size = new System.Drawing.Size(134, 47);
|
||||
this.button3.Size = new System.Drawing.Size(67, 24);
|
||||
this.button3.TabIndex = 6;
|
||||
this.button3.Text = "Swim";
|
||||
this.button3.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// radioButton2
|
||||
//
|
||||
this.radioButton2.AutoSize = true;
|
||||
this.radioButton2.Location = new System.Drawing.Point(4, 43);
|
||||
this.radioButton2.Name = "radioButton2";
|
||||
this.radioButton2.Size = new System.Drawing.Size(98, 17);
|
||||
this.radioButton2.TabIndex = 5;
|
||||
this.radioButton2.TabStop = true;
|
||||
this.radioButton2.Text = "Redhead Duck";
|
||||
this.radioButton2.UseVisualStyleBackColor = true;
|
||||
this.radioButton2.CheckedChanged += new System.EventHandler(this.radioButton2_CheckedChanged);
|
||||
//
|
||||
// radioButton3
|
||||
//
|
||||
this.radioButton3.AutoSize = true;
|
||||
this.radioButton3.Location = new System.Drawing.Point(4, 66);
|
||||
this.radioButton3.Name = "radioButton3";
|
||||
this.radioButton3.Size = new System.Drawing.Size(89, 17);
|
||||
this.radioButton3.TabIndex = 6;
|
||||
this.radioButton3.TabStop = true;
|
||||
this.radioButton3.Text = "Rubber Duck";
|
||||
this.radioButton3.UseVisualStyleBackColor = true;
|
||||
this.radioButton3.CheckedChanged += new System.EventHandler(this.radioButton3_CheckedChanged);
|
||||
//
|
||||
// radioButton4
|
||||
//
|
||||
this.radioButton4.AutoSize = true;
|
||||
this.radioButton4.Location = new System.Drawing.Point(4, 89);
|
||||
this.radioButton4.Name = "radioButton4";
|
||||
this.radioButton4.Size = new System.Drawing.Size(86, 17);
|
||||
this.radioButton4.TabIndex = 7;
|
||||
this.radioButton4.TabStop = true;
|
||||
this.radioButton4.Text = "EDcoy Duck";
|
||||
this.radioButton4.UseVisualStyleBackColor = true;
|
||||
this.radioButton4.CheckedChanged += new System.EventHandler(this.radioButton4_CheckedChanged);
|
||||
//
|
||||
// Form1
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(12F, 25F);
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(1497, 935);
|
||||
this.ClientSize = new System.Drawing.Size(748, 486);
|
||||
this.Controls.Add(this.button3);
|
||||
this.Controls.Add(this.button2);
|
||||
this.Controls.Add(this.button1);
|
||||
this.Controls.Add(this.groupBox1);
|
||||
this.Margin = new System.Windows.Forms.Padding(2);
|
||||
this.Name = "Form1";
|
||||
this.Text = "Form1";
|
||||
this.groupBox1.ResumeLayout(false);
|
||||
@@ -140,13 +155,13 @@ namespace Duck_Simulator
|
||||
#endregion
|
||||
|
||||
private System.Windows.Forms.GroupBox groupBox1;
|
||||
private System.Windows.Forms.CheckBox checkBox4;
|
||||
private System.Windows.Forms.CheckBox checkBox3;
|
||||
private System.Windows.Forms.CheckBox checkBox2;
|
||||
private System.Windows.Forms.CheckBox checkBox1;
|
||||
private System.Windows.Forms.Button button1;
|
||||
private System.Windows.Forms.Button button2;
|
||||
private System.Windows.Forms.Button button3;
|
||||
private System.Windows.Forms.RadioButton radioButton1;
|
||||
private System.Windows.Forms.RadioButton radioButton2;
|
||||
private System.Windows.Forms.RadioButton radioButton3;
|
||||
private System.Windows.Forms.RadioButton radioButton4;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -7,14 +7,86 @@ using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
using DuckModel;
|
||||
|
||||
namespace Duck_Simulator
|
||||
{
|
||||
public partial class Form1 : Form
|
||||
{
|
||||
private DuckTypes _selectedDuck = DuckTypes.Default;
|
||||
private DuckBehaviour _duck;
|
||||
|
||||
public Form1()
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
|
||||
}
|
||||
|
||||
void test()
|
||||
{
|
||||
radioButton1.Checked = true;
|
||||
}
|
||||
|
||||
private void button1_Click(object sender, EventArgs e)
|
||||
{
|
||||
switch (_selectedDuck)
|
||||
{
|
||||
case DuckTypes.Mallard:
|
||||
if (!(_duck is MallardDuck))
|
||||
{
|
||||
_duck = new MallardDuck();
|
||||
}
|
||||
break;
|
||||
case DuckTypes.Redhead:
|
||||
if (!(_duck is RedheadDuck))
|
||||
{
|
||||
_duck = new RedheadDuck();
|
||||
}
|
||||
break;
|
||||
case DuckTypes.Rubber:
|
||||
if (!(_duck is RubberDucky))
|
||||
{
|
||||
_duck = new RubberDucky();
|
||||
}
|
||||
break;
|
||||
case DuckTypes.Decoy:
|
||||
if (!(_duck is DecoyDuck))
|
||||
{
|
||||
_duck = new DecoyDuck();
|
||||
}
|
||||
break;
|
||||
default:
|
||||
|
||||
// Show msg box
|
||||
MessageBox.Show("Not a valid duck");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
string msg = _duck.PerformQuack();
|
||||
MessageBox.Show(msg);
|
||||
}
|
||||
|
||||
private void radioButton1_CheckedChanged(object sender, EventArgs e)
|
||||
{
|
||||
if ((sender as RadioButton).Checked)
|
||||
_selectedDuck = DuckTypes.Mallard;
|
||||
}
|
||||
|
||||
private void radioButton4_CheckedChanged(object sender, EventArgs e)
|
||||
{
|
||||
_selectedDuck = DuckTypes.Decoy;
|
||||
}
|
||||
|
||||
private void radioButton3_CheckedChanged(object sender, EventArgs e)
|
||||
{
|
||||
_selectedDuck = DuckTypes.Rubber;
|
||||
}
|
||||
|
||||
private void radioButton2_CheckedChanged(object sender, EventArgs e)
|
||||
{
|
||||
_selectedDuck = DuckTypes.Redhead;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,6 +17,7 @@ namespace Duck_Simulator
|
||||
Application.EnableVisualStyles();
|
||||
Application.SetCompatibleTextRenderingDefault(false);
|
||||
Application.Run(new Form1());
|
||||
//
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -78,5 +78,11 @@
|
||||
<ItemGroup>
|
||||
<None Include="App.config" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\DuckModel\DuckModel.csproj">
|
||||
<Project>{3085be3e-81c7-48a4-b62a-80e8ba453dac}</Project>
|
||||
<Name>DuckModel</Name>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
</Project>
|
||||
Reference in New Issue
Block a user