add Programmyday form github

This commit is contained in:
Ruben Kallinich
2024-07-25 15:47:46 +02:00
parent 09c8eab938
commit 7362c3d7ce
132 changed files with 3669 additions and 0 deletions

View File

@@ -0,0 +1,47 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace LohnabrechnungMusterlösung
{
enum Tarigruppe
{
A, B, C, D
}
internal class Angstellter : Mitarbeiter
{
private int alter;
private Tarigruppe tarigruppe;
public Angstellter(string? vorname, string? nachname, int alter, Tarigruppe tarigruppe) : base(vorname, nachname)
{
this.vorname = vorname;
this.nachname = nachname;
this.alter = alter;
this.tarigruppe = tarigruppe;
GehaltBerechnen();
}
public void GehaltBerechnen()
{
double grundgehalt = 0;
switch (this.tarigruppe)
{
case Tarigruppe.A:
grundgehalt = 2560;
break;
case Tarigruppe.B:
grundgehalt = 3000;
break;
case Tarigruppe.C:
grundgehalt = 3200;
break;
case Tarigruppe.D:
grundgehalt = 5400;
break;
}
gehalt = grundgehalt * (1 + (alter - 25) / 100.0);
}
}
}

View File

@@ -0,0 +1,42 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace LohnabrechnungMusterlösung
{
internal class Department
{
protected string? bezeichnung;
protected double gehalt;
public double GetGehalt()
{
return gehalt;
}
}
class Sales : Department
{
public Sales()
{
bezeichnung = "Vertrieb";
gehalt = 820;
}
}
class Production : Department
{
public Production()
{
bezeichnung = "Produktion";
}
}
class Development : Department
{
public Development()
{
bezeichnung = "Entwicklung";
gehalt = 935;
}
}
}

View File

@@ -0,0 +1,26 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace LohnabrechnungMusterlösung
{
internal class ExternerMitarbeiter : Mitarbeiter
{
private int projektStunden;
private const int stundenLohn = 75;
public ExternerMitarbeiter(string? vorname, string? nachname, int projektStunden) : base(vorname, nachname)
{
this.vorname = vorname;
this.nachname = nachname;
this.projektStunden = projektStunden;
GehaltBerechnung();
}
public void GehaltBerechnung()
{
gehalt = projektStunden * stundenLohn;
}
}
}

View 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>

View File

@@ -0,0 +1,28 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net.Http.Headers;
using System.Text;
using System.Threading.Tasks;
namespace LohnabrechnungMusterlösung
{
internal class Mitarbeiter
{
protected string? vorname;
protected string? nachname;
protected double gehalt;
public Mitarbeiter(string? vorname, string? nachname)
{
this.vorname = vorname;
this.nachname = nachname;
}
public void DatenAusgabe()
{
Console.WriteLine($"Vorname: {this.vorname}");
Console.WriteLine($"Nachname: {this.nachname}");
Console.WriteLine($"Gehalt: {this.gehalt:C2}");
}
}
}

View File

@@ -0,0 +1,25 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace LohnabrechnungMusterlösung
{
internal class Praktikant : Mitarbeiter
{
private Department abteilung;
public Praktikant(string? vorname, string? nachname, Department abteilung) : base(vorname, nachname)
{
this.vorname = vorname;
this.nachname = nachname;
this.abteilung = abteilung;
GehaltBerechnen();
}
public void GehaltBerechnen()
{
this.gehalt = abteilung.GetGehalt();
}
}
}

View File

@@ -0,0 +1,20 @@
using System.Runtime.CompilerServices;
namespace LohnabrechnungMusterlösung
{
internal class Program
{
static void Main(string[] args)
{
Mitarbeiter[] mitarbeiter = new Mitarbeiter[3];
mitarbeiter[0] = new ExternerMitarbeiter("Harry", "Potter", 135);
mitarbeiter[1] = new Praktikant("Newt", "Scamander", new Development());
mitarbeiter[2] = new Angstellter("Lord", "Voldemort", 71, Tarigruppe.D);
foreach (var item in mitarbeiter)
{
item.DatenAusgabe();
}
}
}
}