Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace ConsoleApplication5
- {
- class Program
- {
- static void Main(string[] args)
- {
- bool beenden = true;
- while (beenden)
- {
- Console.Clear();
- Console.WriteLine("---Programm-ApfelKiste---");
- Console.WriteLine("[K]iste\n[B]raeburn\n[E]lster\n[X]Beenden");
- char ch = Console.ReadKey(true).KeyChar;
- switch (ch)
- {
- case 'k':
- case 'K':
- Apfel apfel1 = new Braeburn();
- Kiste uno = new Kiste();
- uno.addapfel(apfel1);
- Console.WriteLine(uno);
- Console.WriteLine(apfel1.agewicht);
- Console.WriteLine(apfel1.sn);
- Apfel apfel2 = new Braeburn();
- Console.WriteLine(apfel2.agewicht);
- Console.WriteLine(apfel2.sn);
- Console.ReadKey();
- break;
- case 'b':
- case 'B':
- break;
- case 'e':
- case 'E':
- break;
- case 'x':
- case 'X':
- beenden = false;
- Console.WriteLine("Press any key to Exit");
- Console.ReadKey();
- break;
- default:
- Console.WriteLine("FALSCHE EINGABE");
- Console.ReadKey();
- break;
- }
- }
- }
- }
- public class Kiste
- {
- // static int eigengewicht = 300;
- private int _gewicht;
- // private int anzahl = 0;
- // int maxanzahl = 6;
- private List<Apfel> a = new List<Apfel>();
- public int Gewicht
- {
- get
- {
- return _gewicht;
- }
- set
- {
- _gewicht = value;
- }
- }
- public List<Apfel> A
- {
- get
- {
- return a;
- }
- set
- {
- a = value;
- }
- }
- public void addapfel(Apfel _apfel1)
- {
- A.Add(_apfel1);
- }
- public Kiste() { }
- }
- public class Apfel
- {
- private int _SN;
- private int _agewicht;
- public int agewicht
- {
- get
- {
- return _agewicht;
- }
- set
- {
- _agewicht = value;
- }
- }
- public int sn
- {
- get
- {
- return _SN;
- }
- set
- {
- _SN = value;
- }
- }
- public new void Apfell() { }
- }
- class Braeburn : Apfel
- {
- public Braeburn()
- {
- base.Apfell();
- Random Gewicht1 = new Random();
- agewicht = Gewicht1.Next(100, 121);
- Random Serie = new Random();
- sn = Serie.Next(1, 51);
- }
- }
- class Elstar : Apfel
- {
- public Elstar()
- {
- Random gewicht2 = new Random();
- agewicht = gewicht2.Next(110, 141);
- Random Serie = new Random();
- sn = Serie.Next(200, 250);
- }
- }
- }
- /*
- //Apfel apfel1 = new Braeburn();
- //Console.WriteLine(apfel1.agewicht);
- // Console.WriteLine(apfel1.sn);
- Console.ReadKey(); */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement