Guest User

Untitled

a guest
Oct 20th, 2017
144
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.70 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5.  
  6. namespace WS201ß
  7. {
  8. class Koord
  9. {
  10. int x, y;
  11.  
  12. public Koord(int x, int y)
  13. {
  14. this.x = x;
  15. this.y = y;
  16. }
  17.  
  18. static public Koord operator *(Koord k, int faktor)
  19. {
  20. return new Koord(k.x * faktor, k.y * faktor);
  21. }
  22.  
  23. static public Koord operator +(Koord l, Koord m)
  24. {
  25. return new Koord(l.x + m.x, l.y + m.y);
  26. }
  27.  
  28. public override string ToString()
  29. {
  30. return "(" + x + "," + y + ")";
  31. }
  32. }
  33.  
  34. class Adresse
  35. {
  36. protected string Name;
  37. protected string Straße;
  38. protected string PLZ;
  39.  
  40. public Adresse(string name, string straße, string plz)
  41. {
  42. this.Name = name;
  43. this.Straße = straße;
  44. this.PLZ = plz;
  45. }
  46.  
  47. public override string ToString()
  48. {
  49. return "Name: " + Name + " Straße: " + Straße + " PLZ: " + PLZ;
  50. }
  51. }
  52.  
  53. class Mail
  54. {
  55. protected int id;
  56. protected Adresse from, to;
  57. protected bool delivered = true;
  58. static int ID;
  59.  
  60. public Mail(Adresse von, Adresse zu)
  61. {
  62. this.from = von;
  63. this.to = zu;
  64. this.id = ID;
  65. ID++;
  66. }
  67.  
  68. public override string ToString()
  69. {
  70. return "Von: \n" + from + "\nZu: \n" + to;
  71. }
  72. }
  73.  
  74. class Letter : Mail
  75. {
  76. public enum Typ { Standartbrief, Eilbiref };
  77. private Typ t;
  78.  
  79. public Letter(Adresse von, Adresse zu, Typ t)
  80. : base(von, zu)
  81. {
  82. this.t = t;
  83. }
  84.  
  85. public override string ToString()
  86. {
  87. return "Von: \n" + from + "\nZu: \n" + to + "Typ: \n" + t;
  88. }
  89.  
  90. }
  91.  
  92. class Program
  93. {
  94. static void Main(string[] args)
  95. {
  96. //Koord k1 = new Koord(3, 4);
  97. //Koord k2 = new Koord(1, 2);
  98. //Koord k3 = (k1 + k2) * 2;
  99. //Console.WriteLine(k3);
  100.  
  101. Adresse a1 = new Adresse ("Christian", "Sperberstraße 52", "90461");
  102. Adresse a2 = new Adresse ("Hans", "Wiesenweg 11", "90000");
  103. Adresse a3 = new Adresse("Norbert", "Musterweg 1", "91111");
  104. Adresse a4 = new Adresse("Simone", "Lachweg 2", "95445");
  105.  
  106. Mail[] arr = new Mail[2];
  107. arr[0] = new Mail(a1, a2);
  108.  
  109. foreach (Mail i in arr)
  110. {
  111. Console.WriteLine(i.ToString());
  112. }
  113.  
  114.  
  115. }
  116. }
  117. }
Add Comment
Please, Sign In to add comment