add Programmyday form github
This commit is contained in:
47
LohnabrechnungMusterlösung/Angstellter.cs
Normal file
47
LohnabrechnungMusterlösung/Angstellter.cs
Normal 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
42
LohnabrechnungMusterlösung/Department.cs
Normal file
42
LohnabrechnungMusterlösung/Department.cs
Normal 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;
|
||||
}
|
||||
}
|
||||
}
|
||||
26
LohnabrechnungMusterlösung/ExternerMitarbeiter.cs
Normal file
26
LohnabrechnungMusterlösung/ExternerMitarbeiter.cs
Normal 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;
|
||||
}
|
||||
}
|
||||
}
|
||||
10
LohnabrechnungMusterlösung/LohnabrechnungMusterlösung.csproj
Normal file
10
LohnabrechnungMusterlösung/LohnabrechnungMusterlösung.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>
|
||||
28
LohnabrechnungMusterlösung/Mitarbeiter.cs
Normal file
28
LohnabrechnungMusterlösung/Mitarbeiter.cs
Normal 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}");
|
||||
}
|
||||
}
|
||||
}
|
||||
25
LohnabrechnungMusterlösung/Praktikant.cs
Normal file
25
LohnabrechnungMusterlösung/Praktikant.cs
Normal 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();
|
||||
}
|
||||
}
|
||||
}
|
||||
20
LohnabrechnungMusterlösung/Program.cs
Normal file
20
LohnabrechnungMusterlösung/Program.cs
Normal 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();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user