Projektdateien hinzufügen.
This commit is contained in:
10
BeispielKomposition/BeispielKomposition.csproj
Normal file
10
BeispielKomposition/BeispielKomposition.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>
|
||||
33
BeispielKomposition/Building.cs
Normal file
33
BeispielKomposition/Building.cs
Normal file
@@ -0,0 +1,33 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace BeispielKomposition
|
||||
{
|
||||
internal class Building
|
||||
{
|
||||
private string name;
|
||||
private Floor[] floors;
|
||||
|
||||
public Building(string name, int floors)
|
||||
{
|
||||
this.name = name;
|
||||
this.floors = new Floor[floors];
|
||||
for (int i = 0; i < this.floors.Length; i++)
|
||||
{
|
||||
this.floors[i] = new Floor(i);
|
||||
}
|
||||
}
|
||||
public void PrintInfos()
|
||||
{
|
||||
Console.WriteLine($"Gebäude {name}:");
|
||||
foreach (Floor floor in floors)
|
||||
{
|
||||
Console.WriteLine("Etage " + floor.GetFloorid());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
17
BeispielKomposition/Floor.cs
Normal file
17
BeispielKomposition/Floor.cs
Normal file
@@ -0,0 +1,17 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace BeispielKomposition
|
||||
{
|
||||
internal class Floor
|
||||
{
|
||||
private int floorid;
|
||||
|
||||
public Floor(int floorid)
|
||||
{ this.floorid = floorid; }
|
||||
public int GetFloorid() { return floorid; }
|
||||
}
|
||||
}
|
||||
12
BeispielKomposition/Program.cs
Normal file
12
BeispielKomposition/Program.cs
Normal file
@@ -0,0 +1,12 @@
|
||||
namespace BeispielKomposition
|
||||
{
|
||||
internal class Program
|
||||
{
|
||||
static void Main(string[] args)
|
||||
{
|
||||
Building b1 = new Building ("Trump-Tower", 15);
|
||||
|
||||
b1.PrintInfos();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user