Advertisement
Guest User

Untitled

a guest
May 22nd, 2017
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.94 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace ConsoleApplication5
  8. {
  9. class Program
  10. {
  11. static void Main(string[] args)
  12. {
  13. bool beenden = true;
  14. while (beenden)
  15. {
  16. Console.Clear();
  17. Console.WriteLine("---Programm-ApfelKiste---");
  18. Console.WriteLine("[K]iste\n[B]raeburn\n[E]lster\n[X]Beenden");
  19.  
  20. char ch = Console.ReadKey(true).KeyChar;
  21. switch (ch)
  22. {
  23.  
  24. case 'k':
  25. case 'K':
  26. Apfel apfel1 = new Braeburn();
  27. Kiste uno = new Kiste();
  28. uno.addapfel(apfel1);
  29. Console.WriteLine(uno);
  30. Console.WriteLine(apfel1.agewicht);
  31. Console.WriteLine(apfel1.sn);
  32. Apfel apfel2 = new Braeburn();
  33. Console.WriteLine(apfel2.agewicht);
  34. Console.WriteLine(apfel2.sn);
  35. Console.ReadKey();
  36.  
  37. break;
  38. case 'b':
  39. case 'B':
  40.  
  41. break;
  42. case 'e':
  43. case 'E':
  44.  
  45.  
  46. break;
  47. case 'x':
  48. case 'X':
  49. beenden = false;
  50. Console.WriteLine("Press any key to Exit");
  51. Console.ReadKey();
  52.  
  53. break;
  54. default:
  55. Console.WriteLine("FALSCHE EINGABE");
  56. Console.ReadKey();
  57. break;
  58. }
  59.  
  60.  
  61. }
  62.  
  63. }
  64.  
  65. }
  66.  
  67.  
  68. public class Kiste
  69. {
  70. // static int eigengewicht = 300;
  71. private int _gewicht;
  72. // private int anzahl = 0;
  73. // int maxanzahl = 6;
  74. private List<Apfel> a = new List<Apfel>();
  75.  
  76. public int Gewicht
  77. {
  78. get
  79. {
  80. return _gewicht;
  81. }
  82.  
  83. set
  84. {
  85. _gewicht = value;
  86. }
  87. }
  88.  
  89. public List<Apfel> A
  90. {
  91. get
  92. {
  93. return a;
  94. }
  95.  
  96. set
  97. {
  98. a = value;
  99. }
  100. }
  101.  
  102. public void addapfel(Apfel _apfel1)
  103. {
  104. A.Add(_apfel1);
  105.  
  106. }
  107.  
  108. public Kiste() { }
  109.  
  110.  
  111. }
  112.  
  113. public class Apfel
  114. {
  115. private int _SN;
  116. private int _agewicht;
  117. public int agewicht
  118. {
  119. get
  120. {
  121. return _agewicht;
  122. }
  123.  
  124. set
  125. {
  126. _agewicht = value;
  127. }
  128. }
  129.  
  130. public int sn
  131. {
  132. get
  133. {
  134. return _SN;
  135. }
  136.  
  137. set
  138. {
  139. _SN = value;
  140. }
  141. }
  142.  
  143.  
  144. public new void Apfell() { }
  145.  
  146. }
  147.  
  148. class Braeburn : Apfel
  149. {
  150. public Braeburn()
  151. {
  152. base.Apfell();
  153. Random Gewicht1 = new Random();
  154. agewicht = Gewicht1.Next(100, 121);
  155.  
  156. Random Serie = new Random();
  157. sn = Serie.Next(1, 51);
  158. }
  159. }
  160.  
  161. class Elstar : Apfel
  162. {
  163.  
  164. public Elstar()
  165. {
  166. Random gewicht2 = new Random();
  167. agewicht = gewicht2.Next(110, 141);
  168.  
  169. Random Serie = new Random();
  170. sn = Serie.Next(200, 250);
  171. }
  172.  
  173.  
  174. }
  175. }
  176.  
  177. /*
  178.  
  179.  
  180. //Apfel apfel1 = new Braeburn();
  181. //Console.WriteLine(apfel1.agewicht);
  182. // Console.WriteLine(apfel1.sn);
  183. Console.ReadKey(); */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement