Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Immobilie
- {
- protected string ort;
- protected double gesamtgröße, preis;
- public Immobilie(string ort, double gesamtgröße, double preis)
- {
- this.ort = ort;
- this.gesamtgröße = gesamtgröße;
- this.preis = preis;
- }
- public Immobilie() : this(null, 0, 0) { }
- public override string ToString()
- {
- string str = "Ort: "+ ort + "\nGesamtgröße: " + gesamtgröße + "\nPreis: " + preis;
- return str;
- }
- class Mehrfamilienhaus : Immobilie
- {
- double [] wohnflächen = new double [5];
- public Mehrfamilienhaus(string ort, double gesamtgröße, double preis, double[] wohnflächen)
- {
- this.ort = ort;
- this.gesamtgröße = gesamtgröße;
- this.preis = preis;
- this.wohnflächen = wohnflächen;
- }
- public override string ToString()
- {
- return base.ToString()+ "\nWohnflachen" + wohnflächen;
- }
- }
- class Eigentumswohnung : Immobilie
- {
- int baujahr;
- public Eigentumswohnung(string ort, double gesamtgröße, double preis, int baujahr)
- : base (ort, gesamtgröße, preis)
- {
- this.baujahr = baujahr;
- }
- public double Preisproqm()
- {
- return preis / gesamtgröße;
- }
- public override string ToString()
- {
- return base.ToString()+"\nbaujahr: " + baujahr;
- }
- }
- }
- class Program
- {
- static void Main(string[] args)
- {
- Immobilie a = new Immobilie("Erlangen", 300, 15000);
- Immobilie b = new Eigentumswohung("Erlangen", 300, 15000, 2002);
- }
- }
Add Comment
Please, Sign In to add comment