Advertisement
Guest User

sDaniel

a guest
Nov 20th, 2009
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.76 KB | None | 0 0
  1. // Tutorium 6
  2. // 20.11.2009
  3.  
  4. using System;
  5. using System.Collections.Generic;
  6. using System.Linq;
  7. using System.Text;
  8.  
  9. namespace Tutorium_6_1_091120
  10. {
  11.     public class Knopf
  12.     {
  13.         private string beschriftung;
  14.  
  15.         public Knopf(string nBeschriftung)
  16.         {
  17.             if (nBeschriftung.Length > 5)
  18.             {
  19.                 Console.Write("Fehler");
  20.             }
  21.             this.beschriftung = nBeschriftung;
  22.         }
  23.         //Property Beschriftung
  24.         public string Beschriftung
  25.         {
  26.             // string getBeschriftung() {return this.beschriftung; }
  27.             get { return this.beschriftung; }
  28.             set { this.beschriftung = value; }
  29.         }
  30.  
  31.         public override string ToString()
  32.         {
  33.             return "Knopf " + this.beschriftung;
  34.         }
  35.     }
  36.  
  37.     public class Bedienfeld
  38.     {
  39.         List<Knopf> knoepfe;
  40.         public Bedienfeld()
  41.         {
  42.             knoepfe = new List<Knopf>();
  43.         }
  44.  
  45.         public void Add(Knopf nKnopf)
  46.         {
  47.             this.knoepfe.Add(nKnopf);
  48.         }
  49.  
  50.         //public indexer KnopfCount()
  51.         //{
  52.         //    return this.knoepfe.Count;
  53.         //}
  54.  
  55.         public override string ToString()
  56.         {
  57.             string ergebnis = "";
  58.             foreach (Knopf kn in knoepfe)
  59.             {
  60.                 ergebnis = ergebnis + "\n" + kn.ToString();
  61.             }
  62.             return ergebnis;
  63.         }
  64.     }
  65.  
  66.     class Programm
  67.     {
  68.         static void Main(string[] args)
  69.         {
  70.             Knopf k1 = new Knopf("OK");
  71.             k1.Beschriftung = "Speichern";
  72.             Console.WriteLine(k1.Beschriftung);
  73.             Knopf k2 = new Knopf("Hallo Welt");
  74.             Console.ReadKey();
  75.         }
  76.     }
  77. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement