06.11.2026

This commit is contained in:
2026-11-06 12:35:59 +01:00
parent 1db24f80a2
commit be184546df
5 changed files with 68 additions and 9 deletions
@@ -0,0 +1,25 @@
using System;
using System.Collections.Generic;
using System.Text;
namespace ConsoleApp1
{
internal class Angestellter : Person
{
private int employeeID = 0;
public Angestellter(string _firstName, string _lastName, DateTime _birthDay, int _employeeID) : base (_firstName, _lastName, _birthDay)
{
this.employeeID = _employeeID;
}
public void getMitarbeiterInfo()
{
int userage = base.getAge();
string consoleLine = string.Format("Der Mitarbeiter mit der Mitarbeiternummer {0} lautet {1} {2} und ist {3} Jahre alt.", this.employeeID, this.firstName, this.lastName, userage);
Console.WriteLine(consoleLine);
}
}
}
@@ -0,0 +1,26 @@
using System;
using System.Collections.Generic;
using System.Security.Cryptography.X509Certificates;
using System.Text;
namespace ConsoleApp1
{
internal class Kunde : Person
{
private int kdnr = 0;
public Kunde(string _firstName, string _lastName, DateTime _birthDay, int _kdnr) : base(_firstName, _lastName, _birthDay)
{
this.kdnr = _kdnr;
}
public void getKundenInfo()
{
int userage = base.getAge();
string consoleLine = string.Format("Der Kunde mit der Kundennummer {0} lautet {1} {2} und ist {3} Jahre alt.", this.kdnr, this.firstName, this.lastName, userage);
Console.WriteLine(consoleLine);
}
}
}
@@ -8,18 +8,18 @@ namespace ConsoleApp1
internal class Person
{
private string firstName;
private string lastName;
private DateTime birthDay;
protected string firstName;
protected string lastName;
protected DateTime birthDay;
Person(string _firstName, string _lastName, DateTime _birthDay)
public Person(string _firstName, string _lastName, DateTime _birthDay)
{
this.firstName = _firstName;
this.lastName = _lastName;
this.birthDay = _birthDay;
}
private int getAge()
protected int getAge()
{
DateTime curentTIme = DateTime.Now;
int age = curentTIme.Year - birthDay.Year;
@@ -23,11 +23,17 @@ namespace ConsoleApp1
birthDay = Console.ReadLine();
string[] birthDaySplit = birthDay.Split(".");
DateTime defineBirthday = DateTime.Parse("",
DateTime defineBirthday = DateTime.ParseExact(String.Format("{0}-{1}-{2}", birthDaySplit[2], birthDaySplit[1], birthDaySplit[0]), "yyyy-MM-dd", null);
var p1 = new Kunde(firstName, lastName, defineBirthday, 107);
p1.printInfo();
p1.getKundenInfo();
var p2 = new Angestellter(firstName, lastName, defineBirthday, 789);
p2.printInfo();
p2.getMitarbeiterInfo();
//TestMysqlConnection();