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;
- namespace WS201ß
- {
- class Koord
- {
- int x, y;
- public Koord(int x, int y)
- {
- this.x = x;
- this.y = y;
- }
- static public Koord operator *(Koord k, int faktor)
- {
- return new Koord(k.x * faktor, k.y * faktor);
- }
- static public Koord operator +(Koord l, Koord m)
- {
- return new Koord(l.x + m.x, l.y + m.y);
- }
- public override string ToString()
- {
- return "(" + x + "," + y + ")";
- }
- }
- class Adresse
- {
- protected string Name;
- protected string Straße;
- protected string PLZ;
- public Adresse(string name, string straße, string plz)
- {
- this.Name = name;
- this.Straße = straße;
- this.PLZ = plz;
- }
- public override string ToString()
- {
- return "Name: " + Name + " Straße: " + Straße + " PLZ: " + PLZ;
- }
- }
- class Mail
- {
- protected int id;
- protected Adresse from, to;
- protected bool delivered = true;
- static int ID;
- public Mail(Adresse von, Adresse zu)
- {
- this.from = von;
- this.to = zu;
- this.id = ID;
- ID++;
- }
- public override string ToString()
- {
- return "Von: \n" + from + "\nZu: \n" + to;
- }
- }
- class Letter : Mail
- {
- public enum Typ { Standartbrief, Eilbiref };
- private Typ t;
- public Letter(Adresse von, Adresse zu, Typ t)
- : base(von, zu)
- {
- this.t = t;
- }
- public override string ToString()
- {
- return "Von: \n" + from + "\nZu: \n" + to + "Typ: \n" + t;
- }
- }
- class Program
- {
- static void Main(string[] args)
- {
- //Koord k1 = new Koord(3, 4);
- //Koord k2 = new Koord(1, 2);
- //Koord k3 = (k1 + k2) * 2;
- //Console.WriteLine(k3);
- Adresse a1 = new Adresse ("Christian", "Sperberstraße 52", "90461");
- Adresse a2 = new Adresse ("Hans", "Wiesenweg 11", "90000");
- Adresse a3 = new Adresse("Norbert", "Musterweg 1", "91111");
- Adresse a4 = new Adresse("Simone", "Lachweg 2", "95445");
- Mail[] arr = new Mail[2];
- arr[0] = new Mail(a1, a2);
- foreach (Mail i in arr)
- {
- Console.WriteLine(i.ToString());
- }
- }
- }
- }
Add Comment
Please, Sign In to add comment