Exemplo n.º 1
0
 private void buttonSwap_Click(object sender, EventArgs e)
 {
     object Temp;
     Temp = lloyd;
     lloyd = lucinda;
     lucinda = (Elephant)Temp;
     MessageBox.Show("Objects Swapped!");
 }
Exemplo n.º 2
0
        private void button1_Click(object sender, EventArgs e)
        {
            Elephant[] elephants = new Elephant[7];

            elephants[0] = new Elephant {
                Name = "Lloyd", EarSize = 40
            };
            elephants[1] = new Elephant {
                Name = "Lucinda", EarSize = 33
            };
            elephants[2] = new Elephant {
                Name = "Larry", EarSize = 42
            };
            elephants[3] = new Elephant {
                Name = "Lucille", EarSize = 52
            };
            elephants[4] = new Elephant {
                Name = "Lars", EarSize = 44
            };
            elephants[5] = new Elephant {
                Name = "Linda", EarSize = 37
            };
            elephants[6] = new Elephant {
                Name = "Humphrey", EarSize = 45
            };

            Elephant biggestEars = elephants[0];

            for (int i = 1; i < elephants.Length; i++)
            {
                if (elephants[i].EarSize > biggestEars.EarSize)
                {
                    biggestEars = elephants[i];
                }
            }

            MessageBox.Show("The biggest ears belong to " + biggestEars.Name);
        }
Exemplo n.º 3
0
        private void button1_Click(object sender, EventArgs e)
        {
            Elephant[] elephants = new Elephant[7];

            elephants[0] = new Elephant { Name = "Lloyd", EarSize = 40 };
            elephants[1] = new Elephant { Name = "Lucinda", EarSize = 33 };
            elephants[2] = new Elephant { Name = "Larry", EarSize = 42 };
            elephants[3] = new Elephant { Name = "Lucille", EarSize = 52 };
            elephants[4] = new Elephant { Name = "Lars", EarSize = 44 };
            elephants[5] = new Elephant { Name = "Linda", EarSize = 37 };
            elephants[6] = new Elephant { Name = "Humphrey", EarSize = 45 };
            
            Elephant biggestEars = elephants[0];

            for (int i=1; i < elephants.Length; i++)
            {
                if (elephants[i].EarSize > biggestEars.EarSize)
	            {
                    biggestEars = elephants[i];
	            }
            }

            MessageBox.Show("The biggest ears belong to " + biggestEars.Name);
        }
Exemplo n.º 4
0
 public Form1()
 {
     InitializeComponent();
     lucinda = new Elephant() { Name = "Lucinda", EarSize = 33 };
     lloyd = new Elephant() { Name = "Lloyd", EarSize = 40 };
 }
Exemplo n.º 5
0
 public void SpeakTo(Elephant whoToTalkTo, string message)
 {
     whoToTalkTo.TellMe(message, this);
 }
Exemplo n.º 6
0
 public void TellMe(string message, Elephant whoSaidIt)
 {
     System.Windows.Forms.MessageBox.Show(whoSaidIt.Name + " says: " + message);
 }