Guest User

Untitled

a guest
Jun 28th, 2015
306
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.30 KB | None | 0 0
  1. public class Elephant
  2. {
  3. public string Name { get; set; }
  4. public int EarSize { get; set; }
  5.  
  6. public Elephant(string name, int earSize)
  7. {
  8. Name = name;
  9. EarSize = earSize;
  10. }
  11.  
  12. public void WhoIAm()
  13. {
  14. MessageBox.Show("My name is " + Name + " and my ears are " + EarSize + " inches tall.");
  15. }
  16.  
  17.  
  18.  
  19.  
  20.  
  21. public partial class Form1 : Form
  22. {
  23. Elephant elephant1;
  24. Elephant elephant2;
  25.  
  26. public Form1()
  27. {
  28. InitializeComponent();
  29. Elephant elephant1 = new Elephant("Братишка", 20);
  30. Elephant elephant2 = new Elephant("Пахом", 20);
  31. }
  32.  
  33. private void button3_Click(object sender, EventArgs e)
  34. {
  35. Elephant elephantSwap = elephant1;
  36. elephant1 = elephant2;
  37. elephant2 = elephantSwap;
  38. MessageBox.Show("Поменяно.");
  39. Console.WriteLine(elephant1.Name, elephant1.EarSize);
  40. }
  41.  
  42. private void button1_Click(object sender, EventArgs e)
  43. {
  44. elephant1.WhoIAm();
  45. }
  46.  
  47. private void button2_Click(object sender, EventArgs e)
  48. {
  49. elephant2.WhoIAm();
  50.  
  51. }
  52. }
Advertisement
Add Comment
Please, Sign In to add comment