Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Tutorium 6
- // 20.11.2009
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- namespace Tutorium_6_1_091120
- {
- public class Knopf
- {
- private string beschriftung;
- public Knopf(string nBeschriftung)
- {
- if (nBeschriftung.Length > 5)
- {
- Console.Write("Fehler");
- }
- this.beschriftung = nBeschriftung;
- }
- //Property Beschriftung
- public string Beschriftung
- {
- // string getBeschriftung() {return this.beschriftung; }
- get { return this.beschriftung; }
- set { this.beschriftung = value; }
- }
- public override string ToString()
- {
- return "Knopf " + this.beschriftung;
- }
- }
- public class Bedienfeld
- {
- List<Knopf> knoepfe;
- public Bedienfeld()
- {
- knoepfe = new List<Knopf>();
- }
- public void Add(Knopf nKnopf)
- {
- this.knoepfe.Add(nKnopf);
- }
- //public indexer KnopfCount()
- //{
- // return this.knoepfe.Count;
- //}
- public override string ToString()
- {
- string ergebnis = "";
- foreach (Knopf kn in knoepfe)
- {
- ergebnis = ergebnis + "\n" + kn.ToString();
- }
- return ergebnis;
- }
- }
- class Programm
- {
- static void Main(string[] args)
- {
- Knopf k1 = new Knopf("OK");
- k1.Beschriftung = "Speichern";
- Console.WriteLine(k1.Beschriftung);
- Knopf k2 = new Knopf("Hallo Welt");
- Console.ReadKey();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement