Projektdateien hinzufügen.
This commit is contained in:
10
BeispielVererbung/BeispielVererbung.csproj
Normal file
10
BeispielVererbung/BeispielVererbung.csproj
Normal file
@@ -0,0 +1,10 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
</Project>
|
||||
59
BeispielVererbung/Program.cs
Normal file
59
BeispielVererbung/Program.cs
Normal file
@@ -0,0 +1,59 @@
|
||||
namespace BeispielVererbung
|
||||
{
|
||||
internal class Program
|
||||
{
|
||||
static void Main(string[] args)
|
||||
{
|
||||
KFZ k1 = new KFZ();
|
||||
k1.RestwertBerechnen(); //Methode aus KFZ
|
||||
k1.Auszahlen(); //Methode aus Versicherungsobjekt
|
||||
|
||||
Immobilie i1 = new Immobilie();
|
||||
i1.RestwertBerechnen(); //Methode aus Immobilie
|
||||
i1.Auszahlen(); //Methode aus Versicherungsobjekt
|
||||
|
||||
Versicherungsobjekt vo1 = new Versicherungsobjekt();
|
||||
vo1.Auszahlen(); //Nur Methoden der Basisklasse sind sichtbar
|
||||
}
|
||||
}
|
||||
class Versicherungsobjekt
|
||||
{
|
||||
protected double neupreis;
|
||||
protected int baujahr;
|
||||
protected double schadenshöhe;
|
||||
|
||||
public void Auszahlen()
|
||||
{
|
||||
Console.WriteLine("Auszahlung");
|
||||
}
|
||||
}
|
||||
class KFZ : Versicherungsobjekt
|
||||
{
|
||||
private string? hersteller;
|
||||
private string? typenschlüssel;
|
||||
private int laufleistung;
|
||||
|
||||
public void RestwertBerechnen()
|
||||
{
|
||||
Console.WriteLine("Restwert von KFZ");
|
||||
}
|
||||
public void AusgabeAttribute()
|
||||
{
|
||||
Console.WriteLine(this.baujahr );
|
||||
}
|
||||
}
|
||||
class Immobilie : Versicherungsobjekt
|
||||
{
|
||||
private double wohnfläche;
|
||||
private string? lagebewertung;
|
||||
|
||||
public void RestwertBerechnen()
|
||||
{
|
||||
Console.WriteLine("Restwert von Immobilie");
|
||||
}
|
||||
public string? GetLagebewertung()
|
||||
{
|
||||
return lagebewertung;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user