add Programmyday form github
This commit is contained in:
17
zoo-besucher/Adult.cs
Normal file
17
zoo-besucher/Adult.cs
Normal file
@@ -0,0 +1,17 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace zoo_besucher
|
||||
{
|
||||
internal class Adult : Visitor
|
||||
{
|
||||
public Adult()
|
||||
{
|
||||
this.visitorCount = 1;
|
||||
this.entriy = 15;
|
||||
}
|
||||
}
|
||||
}
|
||||
17
zoo-besucher/Child.cs
Normal file
17
zoo-besucher/Child.cs
Normal file
@@ -0,0 +1,17 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace zoo_besucher
|
||||
{
|
||||
internal class Child : Visitor
|
||||
{
|
||||
public Child()
|
||||
{
|
||||
this.visitorCount = 1;
|
||||
this.entriy = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
47
zoo-besucher/Entrance.cs
Normal file
47
zoo-besucher/Entrance.cs
Normal file
@@ -0,0 +1,47 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace zoo_besucher
|
||||
{
|
||||
internal class Entrance
|
||||
{
|
||||
|
||||
private Visitor[] visitor;
|
||||
private int salesVolume;
|
||||
private int visitorCount;
|
||||
public Entrance(int anzahl)
|
||||
{
|
||||
visitor = new Visitor[anzahl];
|
||||
}
|
||||
public bool AddVisitor(Visitor visotorCount)
|
||||
{
|
||||
for (int i = 0; i < visitor.Length; i++)
|
||||
{
|
||||
if (visitor[i] is null)
|
||||
{
|
||||
visitor[i] = visotorCount;
|
||||
salesVolume += visitor[i].GetEntriy();
|
||||
visitorCount += visitor[i].GetVisitorCount();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
public int GetTurnover()
|
||||
{
|
||||
return salesVolume;
|
||||
}
|
||||
public int GetVisitor()
|
||||
{
|
||||
return visitorCount;
|
||||
}
|
||||
public void GetPrintInfo()
|
||||
{
|
||||
Console.WriteLine($"Die Besucherzahlt beträgt: {GetVisitor()}");
|
||||
Console.WriteLine($"Die Einnahmen belaufen sich auf: {GetTurnover()}");
|
||||
}
|
||||
}
|
||||
}
|
||||
17
zoo-besucher/Group.cs
Normal file
17
zoo-besucher/Group.cs
Normal file
@@ -0,0 +1,17 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace zoo_besucher
|
||||
{
|
||||
internal class Group : Visitor
|
||||
{
|
||||
public Group(int visitorCount)
|
||||
{
|
||||
this.entriy = 50;
|
||||
this.visitorCount = visitorCount;
|
||||
}
|
||||
}
|
||||
}
|
||||
19
zoo-besucher/Program.cs
Normal file
19
zoo-besucher/Program.cs
Normal file
@@ -0,0 +1,19 @@
|
||||
namespace zoo_besucher
|
||||
{
|
||||
internal class Program
|
||||
{
|
||||
static void Main(string[] args)
|
||||
{
|
||||
Group gruppe = new Group(20);
|
||||
Adult erwachsene = new Adult();
|
||||
Child kinder = new Child();
|
||||
Entrance eingang = new Entrance(3);
|
||||
|
||||
eingang.AddVisitor(erwachsene);
|
||||
eingang.AddVisitor(kinder);
|
||||
eingang.AddVisitor(gruppe);
|
||||
eingang.AddVisitor(gruppe);
|
||||
eingang.GetPrintInfo();
|
||||
}
|
||||
}
|
||||
}
|
||||
19
zoo-besucher/Visitor.cs
Normal file
19
zoo-besucher/Visitor.cs
Normal file
@@ -0,0 +1,19 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace zoo_besucher
|
||||
{
|
||||
internal class Visitor
|
||||
{
|
||||
protected int visitorCount;
|
||||
protected int entriy;
|
||||
|
||||
public int GetVisitorCount()
|
||||
{ return visitorCount; }
|
||||
public int GetEntriy()
|
||||
{ return entriy; }
|
||||
}
|
||||
}
|
||||
11
zoo-besucher/zoo-besucher.csproj
Normal file
11
zoo-besucher/zoo-besucher.csproj
Normal file
@@ -0,0 +1,11 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
<RootNamespace>zoo_besucher</RootNamespace>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
</Project>
|
||||
Reference in New Issue
Block a user