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

17
AudioPlayer/AudioFile.cs Normal file
View File

@@ -0,0 +1,17 @@
using System;
using System.Collections.Generic;
using System.IO.Enumeration;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace AudioPlayer
{
abstract class AudioFile
{
protected string fileName;
protected string speicherOrt;
public abstract void Play();
}
}

View File

@@ -0,0 +1,55 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net.NetworkInformation;
using System.Runtime.CompilerServices;
using System.Text;
using System.Threading.Tasks;
namespace AudioPlayer
{
internal class AudioPlayer
{
private int id;
private AudioFile[] player;
private Random rnd = new Random();
public AudioPlayer(int cnt)
{
//this.id = id;
this.player = new AudioFile[cnt];
}
public void AddFile(AudioFile file)
{
for (int i = 0; i < player.Length; i++)
{
if (player[i] is null)
{
this.player[i] = file;
break;
}
}
}
public void RemoveFile(int id)
{
if (id >= 0 && id < player.Length)
{
player[id] = null;
}
}
public void Play(AudioFile file)
{
file.Play();
}
public void PlayAll()
{
player = player.OrderBy(i => rnd.Next(player.Length)).ToArray();
for (int i = 0; i < player.Length; i++)
{
if (player[i] is not null)
{
player[i].Play();
}
}
}
}
}

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>

21
AudioPlayer/FLACFile.cs Normal file
View File

@@ -0,0 +1,21 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace AudioPlayer
{
internal class FLACFile : AudioFile
{
public FLACFile(string fileName, string speicherOrt)
{
this.fileName = fileName;
this.speicherOrt = speicherOrt;
}
public override void Play()
{
Console.WriteLine($"{this.fileName} von {this.speicherOrt} vom Typ FLAC wird abgespielt.");
}
}
}

21
AudioPlayer/MP3File.cs Normal file
View File

@@ -0,0 +1,21 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace AudioPlayer
{
internal class MP3File : AudioFile
{
public MP3File(string fileName, string speicherOrt)
{
this.fileName = fileName;
this.speicherOrt = speicherOrt;
}
public override void Play()
{
Console.WriteLine($"{this.fileName} von {this.speicherOrt} vom Typ MP3 wird abgespielt.");
}
}
}

20
AudioPlayer/Program.cs Normal file
View File

@@ -0,0 +1,20 @@
namespace AudioPlayer
{
internal class Program
{
static void Main(string[] args)
{
AudioFile song1 = new MP3File("An Ocean Between Us","bungabunga");
AudioFile song2 = new FLACFile("Lie to me","ungabunga");
AudioFile song3 = new MP3File("Fly high", "ungabungabunga");
AudioFile song4 = new WAVFile("Forever", "bungaunga");
AudioPlayer player = new AudioPlayer(5);
player.AddFile(song1);
player.AddFile(song2);
player.AddFile(song3);
player.AddFile(song4);
player.PlayAll();
}
}
}

21
AudioPlayer/WAVFile.cs Normal file
View File

@@ -0,0 +1,21 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace AudioPlayer
{
internal class WAVFile : AudioFile
{
public WAVFile(string fileName, string speicherOrt)
{
this.fileName = fileName;
this.speicherOrt = speicherOrt;
}
public override void Play()
{
Console.WriteLine($"{this.fileName} von {this.speicherOrt} vom Typ WAV wird abgespielt.");
}
}
}

View File

@@ -0,0 +1,23 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace AudioPlayerMusterlösung
{
abstract class AudioFile
{
private string fileName;
public AudioFile(string filename)
{
this.fileName = filename;
}
public string GetFileName()
{
return fileName;
}
public abstract void Play();
}
}

View File

@@ -0,0 +1,80 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace AudioPlayerMusterlösung
{
internal class AudioPlayer
{
private AudioFile[] audiofiles;
public AudioPlayer(int max)
{
audiofiles = new AudioFile[max];
}
public void AddFile(AudioFile audiofile)
{
for (int i = 0; i < audiofiles.Length; i++)
{
if (audiofiles[i] is null)
{
audiofiles[i] = audiofile;
break;
}
}
}
public void RemoveFile(int id)
{
if (id >= 0 && id < audiofiles.Length)
{
audiofiles[id] = null;
}
}
public void Play(int id)
{
if (id >= 0 && id < audiofiles.Length && audiofiles[id] is null)
{
audiofiles[id].Play();
}
}
public void PlayAll()
{
foreach (AudioFile audio in audiofiles)
{
if (audio is not null)
{
audio.Play();
}
}
}
public void PlayShuffle()
{
Random rnd = new Random();
AudioFile[] playFiles = new AudioFile[audiofiles.Length];
for (int i = 0; i < playFiles.Length; i++)
{
playFiles[i] = audiofiles[i];
}
while (playFiles.Length > 0)
{
int playFile = rnd.Next(playFiles.Length);
if (playFiles[playFile] is not null)
{
playFiles[playFile].Play();
}
AudioFile[] newArray = new AudioFile[playFiles.Length - 1];
for (int i = 0; i < playFile; i++)
{
newArray[i] = playFiles[i];
}
for (int i = playFile; i < newArray.Length; i++)
{
newArray[i] = playFiles[i + 1];
}
playFiles = newArray;
}
}
}
}

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,17 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace AudioPlayerMusterlösung
{
internal class FLACFile : AudioFile
{
public FLACFile(string filename) : base(filename) { }
public override void Play()
{
Console.WriteLine($"FLAC: {GetFileName()}");
}
}
}

View File

@@ -0,0 +1,17 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace AudioPlayerMusterlösung
{
internal class MP3File : AudioFile
{
public MP3File(string filename) : base(filename) { }
public override void Play()
{
Console.WriteLine($"MP3: {GetFileName()}");
}
}
}

View File

@@ -0,0 +1,34 @@
namespace AudioPlayerMusterlösung
{
internal class Program
{
static void Main(string[] args)
{
AudioPlayer iPod = new AudioPlayer(99);
iPod.AddFile(new MP3File("titel 1"));
iPod.AddFile(new MP3File("titel 2"));
iPod.AddFile(new MP3File("titel 3"));
iPod.AddFile(new MP3File("titel 4"));
iPod.AddFile(new MP3File("titel 5"));
iPod.AddFile(new WAVFile("titel 6"));
iPod.AddFile(new WAVFile("titel 7"));
iPod.AddFile(new WAVFile("titel 8"));
iPod.AddFile(new WAVFile("titel 9"));
iPod.AddFile(new WAVFile("titel 10"));
iPod.AddFile(new WAVFile("titel 11"));
iPod.AddFile(new WAVFile("titel 12"));
iPod.AddFile(new FLACFile("titel 13"));
iPod.AddFile(new FLACFile("titel 14"));
iPod.AddFile(new FLACFile("titel 15"));
iPod.AddFile(new FLACFile("titel 16"));
iPod.AddFile(new FLACFile("titel 17"));
iPod.AddFile(new FLACFile("titel 18"));
iPod.AddFile(new MP3File("titel 19"));
iPod.AddFile(new MP3File("titel 20"));
iPod.PlayAll();
Console.WriteLine();
iPod.PlayShuffle();
}
}
}

View File

@@ -0,0 +1,17 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace AudioPlayerMusterlösung
{
internal class WAVFile : AudioFile
{
public WAVFile(string filename) : base(filename) { }
public override void Play()
{
Console.WriteLine($"WAV: {GetFileName()}");
}
}
}

View File

@@ -0,0 +1,58 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Jobs
{
internal class JobVerwaltung
{
private Queue<Jobs> jobsQue = new Queue<Jobs>();
public void AddJob(Jobs jobs)
{
jobsQue.Enqueue(jobs);
int jobId = jobsQue.Count();
if (jobId > 1)
{
Console.WriteLine($"Es sind noch {jobId} Jobs offen");
Console.WriteLine("-----------------------------------");
Console.WriteLine();
}
else
{
Console.WriteLine($"Es ist noch {jobId} Job offen.");
Console.WriteLine("-----------------------------------");
Console.WriteLine();
}
}
public void GetJobDone()
{
if (jobsQue.Count() == 0)
{
Console.WriteLine("Es sind keine Jobs mehr vorhanden.");
Console.WriteLine("-----------------------------------");
Console.WriteLine();
}
else
{
Jobs nextJobs = jobsQue.Dequeue();
Console.WriteLine($"Nächst Job ist {nextJobs}");
int jobId = jobsQue.Count();
Console.WriteLine($"Es sind noch {jobId} offen");
Console.WriteLine("-----------------------------------");
Console.WriteLine();
}
}
public void ShowAllJobs()
{
Console.WriteLine("Alle vorhandenen Jobs: ");
foreach (Jobs jobs in jobsQue)
{
Console.WriteLine($"Folgende Jobs stehen noch aus: {jobs.GetBezeichnung()}");
Console.WriteLine($"Der auftrag kommt von: {jobs.GetAuftraggeber()}");
Console.WriteLine($"Und wird in der Zeit von: {jobs.GetDauer()} Minuten bearbeitet");
}
}
}
}

33
Capitalize/Jobs.cs Normal file
View File

@@ -0,0 +1,33 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Jobs
{
internal class Jobs
{
private string? bezeichnung;
private string? auftraggeber;
private int dauer;
public Jobs(string jobBezeinung, string auftraggeber, int dauer)
{
this.bezeichnung = jobBezeinung;
this.auftraggeber = auftraggeber;
this.dauer = dauer;
}
public string GetBezeichnung()
{
return this.bezeichnung;
}
public string GetAuftraggeber()
{
return this.auftraggeber;
}
public int GetDauer()
{
return this.dauer;
}
}
}

10
Capitalize/Jobs.csproj Normal file
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>

18
Capitalize/Program.cs Normal file
View File

@@ -0,0 +1,18 @@
using System.Runtime.InteropServices;
using System.Threading.Channels;
namespace Jobs
{
internal class Program
{
static void Main(string[] args)
{
JobVerwaltung jobs = new JobVerwaltung();
jobs.AddJob(new Jobs("print","office",104));
jobs.AddJob(new Jobs("Menu","ich",80));
jobs.AddJob(new Jobs("Kaffee kochen","der Chef mir",8));
jobs.GetJobDone();
jobs.ShowAllJobs();
}
}
}

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>

10
ConsoleApp1/Program.cs Normal file
View File

@@ -0,0 +1,10 @@
namespace ConsoleApp1
{
internal class Program
{
static void Main(string[] args)
{
Console.WriteLine("Hello, World!");
}
}
}

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,42 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace DoppelteBuchstaben
{
internal class DuplicateChars
{
private string _text;
public bool ContainsDuplicateChars(string text)
{
for (int i = 0; i < text.Length; i++)
{
for (int j = i + 1; j < text.Length; j++)
{
if (text[i] == text[j])
{
return true;
}
}
}
return false;
}
public string RemoveDuplicateChars(string text)
{
for (int i = 0; i < text.Length; i++)
{
for (int j = i + 1; j < text.Length; j++)
{
if (text[i] == text[j])
{
this._text = text.Remove(j);
return this._text;
}
}
}
return text;
}
}
}

View File

@@ -0,0 +1,13 @@
namespace DoppelteBuchstaben
{
internal class Program
{
static void Main(string[] args)
{
DuplicateChars duplicate = new DuplicateChars();
string text = Console.ReadLine();
Console.WriteLine(duplicate.ContainsDuplicateChars(text));
Console.WriteLine(duplicate.RemoveDuplicateChars(text));
}
}
}

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,37 @@
using System.Runtime.CompilerServices;
using System.Security.Cryptography.X509Certificates;
namespace DoublingExtention
{
internal class Program
{
static void Main(string[] args)
{
string input = "Libelle";
Console.WriteLine(input.Doubling());
}
}
static class DublingExtention
{
public static string Doubling(this string input)
{
char previosChar = '\0'; //PreviosChar wird beim ersten druchlauf nicht geprüft.
char doubling;
for (int i = 0; i < input.Length; i++)
{
char currentChar = input[i];
if (i != 0)
{
previosChar = input[i - 1];
}
if (currentChar == previosChar)
{
doubling = currentChar;
return $"Folgende doppelte Buchstaben wurden gefunden: {doubling}";
}
}
return "Es wurden keine doppelten Buchstaben gefunden.";
}
}
}

20
E-Book/Audio.cs Normal file
View File

@@ -0,0 +1,20 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Text;
using System.Threading.Tasks;
namespace E_Book
{
internal class Audio : MediaAssets
{
private decimal ptis;
private decimal audioPages;
public Audio(decimal ptis)
{
this.ptis = ptis;
this.audioPages = 0;
}
}
}

11
E-Book/E-Book.csproj Normal file
View File

@@ -0,0 +1,11 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net6.0</TargetFramework>
<RootNamespace>E_Book</RootNamespace>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
</Project>

38
E-Book/EBook.cs Normal file
View File

@@ -0,0 +1,38 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace E_Book
{
internal class EBook
{
private string? author;
private string? publishingYear;
private MediaAssets[] media;
private decimal totalPageCount;
public EBook(int number)
{
media = new MediaAssets[number];
}
public bool AddMediaAsset(MediaAssets pageCount)
{
for (int i = 0; i < media.Length; i++)
{
if (media[i] is null)
{
media[i] = pageCount;
totalPageCount += media[i].GetPageCount();
return true;
}
}
return false;
}
public void PrintInof()
{
Console.WriteLine($"Das Buch hat {totalPageCount} Seiten,");
}
}
}

18
E-Book/MediaAssets.cs Normal file
View File

@@ -0,0 +1,18 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace E_Book
{
internal class MediaAssets
{
protected decimal pageCount;
public decimal GetPageCount()
{
return pageCount;
}
}
}

16
E-Book/MediaMath.cs Normal file
View File

@@ -0,0 +1,16 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace E_Book
{
internal static class MediaMath
{
public static decimal DimensionsMath(decimal pixelHeight, decimal pixelWidth)
{
return pixelHeight * (960 / pixelWidth);
}
}
}

30
E-Book/Picture.cs Normal file
View File

@@ -0,0 +1,30 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace E_Book
{
internal class Picture : MediaAssets
{
private decimal pixelWidth;
private decimal pixelHeight;
private decimal aspectraiton;
public Picture(decimal pixelHeight, decimal pixelWidth)
{
this.pixelHeight = pixelHeight;
this.pixelWidth = pixelWidth;
this.aspectraiton = MediaMath.DimensionsMath(this.pixelHeight,this.pixelWidth);
if (this.aspectraiton > 600)
{
this.pageCount = 1;
}
else
{
this.pageCount = 1 / 2;
}
}
}
}

19
E-Book/Program.cs Normal file
View File

@@ -0,0 +1,19 @@
namespace E_Book
{
internal class Program
{
static void Main(string[] args)
{
MediaAssets text = new Texte(20);
MediaAssets video = new Video(20,49);
MediaAssets picture = new Picture(100, 200);
MediaAssets audio = new Audio(0);
EBook eBook = new EBook(50);
eBook.AddMediaAsset(text);
eBook.AddMediaAsset(video);
eBook.AddMediaAsset(picture);
eBook.AddMediaAsset(audio);
eBook.PrintInof();
}
}
}

18
E-Book/Texte.cs Normal file
View File

@@ -0,0 +1,18 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace E_Book
{
internal class Texte : MediaAssets
{
private decimal charCount;
public Texte(decimal charCount)
{
this.charCount = charCount;
this.pageCount = Math.Ceiling(charCount / 2000);
}
}
}

30
E-Book/Video.cs Normal file
View File

@@ -0,0 +1,30 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Security.Cryptography.X509Certificates;
using System.Text;
using System.Threading.Tasks;
namespace E_Book
{
internal class Video : MediaAssets
{
private decimal pixelWidth;
private decimal pixelHeight;
private decimal aspectraiton;
public Video(decimal pixelHeight, decimal pixelWidth)
{
this.pixelHeight = pixelHeight;
this.pixelWidth = pixelWidth;
this.aspectraiton = MediaMath.DimensionsMath(this.pixelHeight, this.pixelWidth);
if (this.aspectraiton > 600)
{
this.pageCount = 1;
}
else
{
this.pageCount = 1 / 2;
}
}
}
}

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,22 @@
namespace EvenOrOddExtention
{
internal class Program
{
static void Main(string[] args)
{
int input = 105;
Console.WriteLine(input.EvenOrOdd());
}
}
static class EvenOrOddExtention
{
public static string EvenOrOdd(this int input)
{
if (input % 2 != 0)
{
return "Odd";
}
return "Even";
}
}
}

View File

@@ -0,0 +1,24 @@
namespace SplitWordIntoCountExtensionMethod
{
internal class Program
{
static void Main(string[] args)
{
string input = "Das ist der Versuch nummer 1";
Console.WriteLine($"Word count: {input.SplitIntoWords()}");
}
}
static class WordCountExtension
{
public static int SplitIntoWords(this string input)
{
int freq = 0;
string[] index = input.Split(" ");
for (int i = 0; i < index.Length; i++)
{
freq++;
}
return freq;
}
}
}

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,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,27 @@
using System.Text;
namespace ExtensionMethods
{
internal class Program
{
static void Main(string[] args)
{
string text = "Abra Kadabra";
Console.WriteLine(text);
Console.WriteLine(text.SwitchCase());
}
}
static class StringExtensions
{
public static string SwitchCase(this string s)
{
StringBuilder sb = new StringBuilder();
foreach (char c in s)
{
sb.Append(char.IsUpper(c) ? char.ToLower(c) : char.ToUpper(c));
}
return sb.ToString();
}
}
}

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,49 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace IBANNummerPrüfen
{
public class IbanPrüfung
{
// Richtiges IBAN Format: DE68 2105 0170 0012 3456 78
//private string? IBAN;
private string? ibanCleared;
private string? ibanSwapped;
private string? sum;
private string? iban;
public void SetIbanPrüfungEntgegennehmen()
{
Console.Write("Bitte geben Sie ihre IBAN-Nummer ein: ");
this.iban = Console.ReadLine();
Console.WriteLine(IBANPrüfung());
}
/// <summary>
/// Bestimmt ob die Checksumme einer IBAN gültig ist
/// </summary>
/// <param name="iban">Der zu prüfende IBAN (z.B: "DE68 2105 0170 0012 3456 78")</param>
/// <returns><c>True</c>, wenn <paramref name="value"/> gültig ist. Andernfalls <c>False</c>.</returns>
public bool IBANPrüfung()
{
if (this.iban != null)
{
this.ibanCleared = this.iban.ToUpper().Replace(" ", "").Replace("-", "").Replace(".", "");
//Console.WriteLine(ibanCleared);
this.ibanSwapped = ibanCleared.Substring(4) + ibanCleared.Substring(0, 4);
//Console.WriteLine(ibanSwapped);
this.sum = ibanSwapped.Aggregate("", (current, c) => current + (char.IsLetter(c) ? (c - 55).ToString() : c.ToString()));
//Console.WriteLine(sum);
//this.sum = ibanCleared.Aggregate("", (current, c) => current + (char.IsLetter(c) ? (c - 55).ToString() : c.ToString()));
var d = decimal.Parse(sum);
return ((d % 97) == 1);
}
return false;
}
}
}

View File

@@ -0,0 +1,11 @@
namespace IBANNummerPrüfen
{
internal class Program
{
static void Main(string[] args)
{
IbanPrüfung iban = new IbanPrüfung();
iban.SetIbanPrüfungEntgegennehmen();
}
}
}

10
KFZ/KFZ.csproj Normal file
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>

34
KFZ/Program.cs Normal file
View File

@@ -0,0 +1,34 @@
namespace KFZ
{
internal class Program
{
static void Main(string[] args)
{
PKW p = new PKW(42);
}
}
class Fahrzeuge
{
private int id;
public Fahrzeuge()
{
Console.WriteLine("Fahrzeuge ohne Para");
}
public Fahrzeuge(int id)
{
this.id = id;
Console.WriteLine("Fahrzeug mit Para");
}
}
class PKW : Fahrzeuge
{
public PKW()
{
Console.WriteLine("Pkw ohne Para");
}
public PKW(int id) : base(id)
{
Console.WriteLine("Pkw mit Para");
}
}
}

View File

@@ -0,0 +1,42 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Lohnabrechnung
{
internal class Angestellter : Lohnsklaven
{
private int alter;
private string? tarifgruppe;
public Angestellter(int alter, string? tarifgruppe, string? name, string? vorname)
{
this.alter = alter;
this.tarifgruppe = tarifgruppe;
this.name = name;
this.vorname = vorname;
hungerlohn();
}
public void hungerlohn()
{
if (tarifgruppe == "A" || tarifgruppe == "a")
{
this.gehalt = 2560 * (1 + ((this.alter - 25.0) / 100));
}
else if (tarifgruppe == "B" || tarifgruppe == "b")
{
this.gehalt = 3000 * (1 + ((this.alter - 25.0) / 100));
}
else if (tarifgruppe == "C" || tarifgruppe == "c")
{
this.gehalt = 3200 * (1 + ((this.alter - 25.0) / 100));
}
else if (tarifgruppe == "D" || tarifgruppe == "d")
{
this.gehalt = 5400 * (1 + ((this.alter - 25.0) / 100));
}
}
}
}

View File

@@ -0,0 +1,25 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Lohnabrechnung
{
internal class ExternerMitarbeiter : Lohnsklaven
{
private int projektstunden;
public ExternerMitarbeiter(int projektstunden, string? name, string? vorname)
{
this.projektstunden = projektstunden;
this.name = name;
this.vorname = vorname;
Berechnung();
}
public void Berechnung()
{
this.gehalt = projektstunden * 75;
}
}
}

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,35 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Lohnabrechnung
{
internal class Lohnsklaven
{
protected string? name;
protected string? vorname;
protected double gehalt;
public void DatenAusgabe()
{
if (this is Angestellter)
{
Console.WriteLine("Angestellter:");
}
else if(this is ExternerMitarbeiter)
{
Console.WriteLine("Externer Mitarbeiter:");
}
else if (this is Praktikant)
{
Console.WriteLine("Praktikant:");
}
Console.WriteLine($"Name: {name}");
Console.WriteLine($"Vorname: {vorname}");
Console.WriteLine($"Gehalt: {gehalt:C2}");
Console.WriteLine();
}
}
}

View File

@@ -0,0 +1,29 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Lohnabrechnung
{
internal class Praktikant : Lohnsklaven
{
private string? abteilung;
public Praktikant(string? abteilung, string? name, string? vorname)
{
this.abteilung = abteilung;
this.name = name;
this.vorname = vorname;
fußabtreter();
}
public void fußabtreter()
{
if (this.abteilung == "Entwicklung")
{ this.gehalt = 935; }
else if (this.abteilung == "Vertreib")
{ this.gehalt = 820; }
else if (this.abteilung == "Procuktion")
{ this.gehalt = 710; }
}
}
}

17
Lohnabrechnung/Program.cs Normal file
View File

@@ -0,0 +1,17 @@
using System.Threading.Channels;
namespace Lohnabrechnung
{
internal class Program
{
static void Main(string[] args)
{
Angestellter angestellter1 = new Angestellter(31,"B","Goldfisch","Robertus");
ExternerMitarbeiter externer = new ExternerMitarbeiter(900, "Lumpen", "Struppi");
Praktikant prakti = new Praktikant("Entwicklung", "Gans", "Gustav");
angestellter1.DatenAusgabe();
externer.DatenAusgabe();
prakti.DatenAusgabe();
}
}
}

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();
}
}
}
}

80
Moped/MitAnhänger.cs Normal file
View File

@@ -0,0 +1,80 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Moped
{
internal class MitAnhänger : Moped
{
private int maxLoad;
private int currentLoad;
//public MitAnhänger(int kilometerstand, bool isSportModel, int maxLadeFläche) : base( kilometerstand, isSportModel)
//{
// this.licencePlate = "BIT-LC 1";
// this.odometer = kilometerstand;
// this.seats = 2;
// this.maxLadeFläche = maxLadeFläche;
//}
//public MitAnhänger(string kennzeichen, int kilometerstand, bool isSportModel, int maxLadeFläche) : base(kennzeichen, kilometerstand, isSportModel)
//{
// this.licencePlate = kennzeichen;
// this.odometer = kilometerstand;
// this.seats = 2;
// this.maxLadeFläche = maxLadeFläche;
//}
public MitAnhänger() : this(10, "BIT-LC 1") { }
public MitAnhänger(string licencePlate) : this(10, licencePlate) { }
public MitAnhänger(int maxLoad) : this(maxLoad, "BIT-LC 1") { }
public MitAnhänger(int maxLoad, string licencePlate) : base(licencePlate)
{
this.maxLoad = maxLoad;
}
public bool Load(int x)
{
if (x >= 0 && this.currentLoad + x <= this.maxLoad)
{
this.currentLoad += x;
Console.WriteLine($"Es wurden {x} Dinge aufgeladen.");
return true;
}
else
{
Console.WriteLine($"Es ist nicht genug Platz für {x} Dinge.");
return false;
}
}
public bool Unload(int x)
{
if (x >= 0 && this.currentLoad >= x)
{
this.currentLoad -= x;
Console.WriteLine($"Es wurden {x} Dinge abgeladen.");
return true;
}
else
{
Console.WriteLine($"Es sind keine {x} Dinge vorhanden.");
return false;
}
}
public int GetLoad()
{
return currentLoad;
}
//public override void GetInfos()
//{
// base.GetInfos();
// Console.WriteLine($"Die ladung des Anhängers beträgt {GetLoad()}");
// Console.WriteLine();
//}
public override void GetInfos()
{
base.GetInfos();
Console.WriteLine($"Ladefläche: {currentLoad}");
Console.WriteLine($"Ladefläche max: {maxLoad}");
}
}
}

80
Moped/Moped.cs Normal file
View File

@@ -0,0 +1,80 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Moped
{
internal class Moped
{
protected string licencePlate;
protected int odometer;
protected int seats;
public Moped() : this("Bit-LC 1", false) { }
public Moped(bool IsSportModel) : this("BIT-LC 1", IsSportModel) { }
public Moped(string licenePlate) : this(licenePlate, false) { }
public Moped(string licencePlate, bool IsSportModel)
{
this.licencePlate = licencePlate;
this.seats = IsSportModel ? 1 : 0;
}
//public Moped(int kilometerstand, bool isSportModel)
//{
// this.licencePlate = "BIT-LC 1";
// this.odometer = kilometerstand;
// this.seats = isSportModel ? 1 : 2;
//}
//public Moped(string kennzeichen, int kilometerstand, bool isSportModel)
//{
// this.licencePlate = kennzeichen;
// this.odometer = kilometerstand;
// this.seats = isSportModel ? 1 : 2;
//}
public void Drive(int x)
{
this.odometer += x;
Console.WriteLine($"Das Moped fährt {x} Kilometer.");
}
public string GetLicensePlatte()
{
return this.licencePlate;
}
public int GetOdometer()
{
return this.odometer;
}
public int GetSeats()
{
if (seats == 1)
{
return this.seats = 1;
}
else
{
return this.seats = 2;
}
}
public virtual void GetInfos()
{
Console.WriteLine($"Kennzeichen: {GetLicensePlatte()}");
Console.WriteLine($"Kilometer: {GetOdometer()}");
Console.WriteLine($"Sitzsplätze: {GetSeats()}");
}
//public virtual void GetInfos()
//{
// Console.WriteLine($"Das Moped hat folgendes Kennzeichen:{licencePlate}");
// Console.WriteLine($"Das Moped hat folgenden Kilometerstand:{odometer}");
// if (this.seats == 1)
// {
// Console.WriteLine($"Sport Moped hat nur 1 Sitzsplatz");
// }
// else
// {
// Console.WriteLine($"Normale Mopeds haben 2 Sitzpätze");
// }
//}
}
}

10
Moped/Moped.csproj Normal file
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>

45
Moped/Program.cs Normal file
View File

@@ -0,0 +1,45 @@
namespace Moped
{
internal class Program
{
static void Main(string[] args)
{
//Moped m1 = new Moped(200, 0);
//Moped m2 = new Moped("UN DO : 022",200, 1);
//MitAnhänger ma1 = new MitAnhänger(200,2,30);
//m1.Drive(50);
//m1.GetInfos();
//Console.WriteLine();
//ma1.GetInfos();
//ma1.Load(15);
//ma1.GetInfos();
//ma1.Unload(4);
//ma1.GetInfos();
Moped[] mopeds = new Moped[4];
mopeds[0] = new Moped();
mopeds[1] = new Moped("xyz");
mopeds[2] = new Moped(true);
mopeds[3] = new Moped("ABC", true);
//mopeds[2].Drive(50);
//mopeds[0].Drive(100);
foreach (var item in mopeds)
{
item.GetInfos();
Console.WriteLine();
}
MitAnhänger ma1 = new MitAnhänger(100,"UN-IT 4666");
ma1.GetInfos();
Console.WriteLine();
mopeds[3] = ma1;
foreach (var item in mopeds)
{
item.GetInfos();
Console.WriteLine();
}
}
}
}

28
Palindrom/IsPalindrom.cs Normal file
View File

@@ -0,0 +1,28 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Palindrom
{
internal class IsPalindrom
{
private string _text;
public bool IstDasEinPalindrom(string text)
{
this._text = text.ToLower();
this._text = text.Replace(" ", "");
for (int i = text.Length - 1; i < 0; i--)
{
this._text.Append(text[i]);
}
if (this._text == text)
{
return true;
}
return false;
}
}
}

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>

14
Palindrom/Program.cs Normal file
View File

@@ -0,0 +1,14 @@
using System.Threading.Channels;
namespace Palindrom
{
internal class Program
{
static void Main(string[] args)
{
IsPalindrom palindrom = new IsPalindrom();
string x = Console.ReadLine();
Console.WriteLine(palindrom.IstDasEinPalindrom(x));
}
}
}

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,26 @@
namespace PalindromeExtention
{
internal class Program
{
static void Main(string[] args)
{
string input = "otto";
Console.WriteLine(input.Palindrom());
}
}
static class PalindormExtention
{
public static bool Palindrom(this string input)
{
string index = input.Replace(" ","").ToLower();
for (int i = 0; i < index.Length / 2; i++)
{
if (index[i] != index[index.Length - i - 1])
{
return false;
}
}
return true;
}
}
}

22
Parkplatz/Auto.cs Normal file
View File

@@ -0,0 +1,22 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Parkplatz
{
internal class Auto
{
private string kennzeichen;
public Auto(string kennzeichen)
{
this.kennzeichen = kennzeichen;
}
public string GetKennzeichen()
{
return kennzeichen;
}
}
}

35
Parkplatz/Parkboxen.cs Normal file
View File

@@ -0,0 +1,35 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Parkplatz
{
internal class Parkboxen
{
private Auto? auto;
public bool einparken(Auto auto)
{
if (this.auto == null)
{
this.auto = auto;
return true;
}
else return false;
}
public Auto ausparken(string kennzeichen)
{
if (this.auto.GetKennzeichen() == kennzeichen)
{
Auto h = this.auto;
this.auto = null;
return h;
}
else return null;
}
public bool istleer() { return this.auto == null; }
}
}

61
Parkplatz/Parkplatz.cs Normal file
View File

@@ -0,0 +1,61 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Parkplatz
{
internal class Parkplatz
{
private int anzahlParkboxen;
private Parkboxen[] parkboxen;
public Parkplatz(int anzahlParkboxen)
{
this.anzahlParkboxen = anzahlParkboxen;
this.parkboxen = new Parkboxen[anzahlParkboxen];
for (int i = 0; i < parkboxen.Length; i++)
{
this.parkboxen[i] = new Parkboxen();
}
}
public bool parken(Auto auto)
{
for (int i = 0; i < parkboxen.Length; i++)
{
if (parkboxen[i].einparken(auto))
{
return true;
}
}
return false;
}
public Auto ausparken(string kennzeichen)
{
for (int i = 0; i < anzahlParkboxen; i++)
{
Auto a = parkboxen[i].ausparken(kennzeichen);
if (a != null)
{
return a;
}
}
return null;
}
public void status()
{
Console.WriteLine("Parkplatz-Status: ");
for (int i = 0; i < anzahlParkboxen; i++)
{
if (parkboxen[i].istleer())
{
Console.Write("[ ]");
}
else Console.Write("[X]");
}
Console.WriteLine();
}
}
}

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>

32
Parkplatz/Program.cs Normal file
View File

@@ -0,0 +1,32 @@
namespace Parkplatz
{
internal class Program
{
static void Main(string[] args)
{
Parkplatz parkplatz = new Parkplatz(100);
Auto auto1 = new Auto("ABC-123");
Auto auto2 = new Auto("DEF-456");
Auto auto3 = new Auto("GHI-789");
Auto auto4 = new Auto("IJK-101");
Auto auto5 = new Auto("LMN-102");
Auto auto6 = new Auto("OPQ-103");
Auto auto7 = new Auto("RST-104");
Auto auto8 = new Auto("UVW-105");
Auto auto9 = new Auto("XYZ-106");
parkplatz.status();
Console.WriteLine();
parkplatz.parken(auto1);
parkplatz.parken(auto2);
parkplatz.parken(auto3);
parkplatz.parken(auto4);
parkplatz.status();
parkplatz.ausparken("DEF-456");
parkplatz.status();
Console.ReadKey();
}
}
}

22
Parkplatz2/Auto.cs Normal file
View File

@@ -0,0 +1,22 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Parkplatz2
{
class Auto
{
private string kennzeichen;
public Auto(string kennzeichen)
{
this.kennzeichen = kennzeichen;
}
public string GetKennzeichen()
{
return kennzeichen;
}
}
}

49
Parkplatz2/Parkbox.cs Normal file
View File

@@ -0,0 +1,49 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Parkplatz2
{
class Parkbox
{
private int id;
private Auto auto;
public Parkbox(int id)
{
this.id = id;
}
public int GetId()
{
return id;
}
public bool IstLeer()
{
return auto == null;
}
public bool Einparken(Auto auto)
{
if (IstLeer())
{
this.auto = auto;
return true;
}
return false;
}
public Auto Ausparken(string kennzeichen)
{
if (!IstLeer())
{
if (kennzeichen == auto.GetKennzeichen())
{
Auto help = auto;
auto = null;
return help;
}
}
return null;
}
}
}

76
Parkplatz2/Parkplatz.cs Normal file
View File

@@ -0,0 +1,76 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Parkplatz2
{
internal class Parkplatz
{
private int id;
private Parkbox[] parkboxen;
//private Parkschein parkschein;
public Parkplatz(int id, int anzahl)
{
this.id = id;
this.parkboxen = new Parkbox[anzahl];
for (int i = 0; i < this.parkboxen.Length; i++)
{
this.parkboxen[i] = new Parkbox(i);
}
}
public int GetId()
{ return this.id; }
public int FreiePlätze()
{
int anzahl = 0;
for (int i = 0; i < this.parkboxen.Length; i++)
{
if (this.parkboxen[i].IstLeer())
{
anzahl++;
}
}
return anzahl;
}
public Parkschein Einparken(Auto auto)
{
for (int i = 0; i < this.parkboxen.Length; i++)
{
if (this.parkboxen[i].IstLeer())
{
if (this.parkboxen[i].Einparken(auto))
{
Parkschein ps = new Parkschein(this.id, parkboxen[i].GetId(),auto.GetKennzeichen());
Console.WriteLine($"Das Auto wurde in {this.parkboxen[i].GetId()} eingeparkt.");
return ps;
}
}
}
Console.WriteLine("Das Auto konnte nicht eingeparkt werden.");
return null;
}
public Auto Ausparken(Parkschein ps)
{
if (ps.GetParkplatzId() == this.id)
{
for (int i = 0; i < this.parkboxen.Length; i++)
{
if (ps.GetParboxId() == this.parkboxen[i].GetId())
{
Auto rückgabe = this.parkboxen[i].Ausparken(ps.GetKennzeichen());
if (rückgabe != null)
{
Console.WriteLine($"Das Auto wurde aus PB {this.parkboxen[i].GetId()} ausgeparkt.");
return rückgabe;
}
}
}
}
Console.WriteLine("Auto konnte nicht ausgeparkt werden. Es existiert nicht");
return null;
}
}
}

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>

36
Parkplatz2/Parkschein.cs Normal file
View File

@@ -0,0 +1,36 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Security.Cryptography.X509Certificates;
using System.Text;
using System.Threading.Tasks;
namespace Parkplatz2
{
internal class Parkschein
{
private int parkboxId;
private int parkplatzId;
private string kennzeichen;
public Parkschein (int parkplatzId, int parkboxId, string kennzeichen)
{
this.parkboxId = parkboxId;
this.kennzeichen = kennzeichen;
this.parkplatzId = parkplatzId;
}
public string GetKennzeichen()
{
return this.kennzeichen;
}
public int GetParkplatzId()
{
return this.parkplatzId;
}
public int GetParboxId()
{
return this.parkboxId;
}
}
}

32
Parkplatz2/Program.cs Normal file
View File

@@ -0,0 +1,32 @@
using System;
namespace Parkplatz2
{
class Program
{
static void Main(string[] args)
{
Auto a1 = new Auto("UN-IT 4666");
Auto a2 = new Auto("UN-IT 92");
Auto a3 = new Auto("UN-IT 91");
Auto a4 = new Auto("UN-IT 7666");
Auto a5 = new Auto("UN-IT 6666");
Auto a6 = new Auto("UN-IT 5666");
Parkplatz p1 = new Parkplatz(1, 5);
Console.WriteLine("Freie Plätze: " + p1.FreiePlätze());
Parkschein ps1 = p1.Einparken(a1);
Console.WriteLine(ps1.GetParkplatzId());
Console.WriteLine(ps1.GetParboxId());
Console.WriteLine(ps1.GetKennzeichen());
Console.WriteLine();
a1 = null;
a1 = p1.Ausparken(ps1);
Console.WriteLine(a1.GetKennzeichen());
}
}
}

24
Simpsons/Bart.cs Normal file
View File

@@ -0,0 +1,24 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Simpsons
{
internal class Bart : Familie
{
public Bart()
{
this.vorname = " Bart";
}
public void skateboardGefahren()
{
this.zähler++;
}
public void ausgabe()
{
Console.WriteLine($"{this.zähler} Skateboard gefahren.");
}
}
}

25
Simpsons/Familie.cs Normal file
View File

@@ -0,0 +1,25 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Simpsons
{
internal class Familie
{
protected string? vorname;
protected string? nachname = " Simpsons";
protected string? hautfarbe = " Gelb";
protected string? wohnort = " Evergreen Terrace 742, Springfeield";
protected int zähler;
public void vorstellung()
{
Console.WriteLine($"Vorname: {this.vorname}");
Console.WriteLine($"Nachname: {this.nachname}");
Console.WriteLine($"Hautfarbe: {this.hautfarbe}");
Console.WriteLine($"Wohnort: {this.wohnort}");
}
}
}

24
Simpsons/Homer.cs Normal file
View File

@@ -0,0 +1,24 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Simpsons
{
internal class Homer : Familie
{
public Homer()
{
this.vorname = " Homer";
}
public void donutsGegessen()
{
this.zähler++;
}
public void ausgabe()
{
Console.WriteLine($"{this.zähler} Dounats gegessen.");
}
}
}

24
Simpsons/Lisa.cs Normal file
View File

@@ -0,0 +1,24 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Simpsons
{
internal class Lisa : Familie
{
public Lisa()
{
this.vorname = " Lisa";
}
public void saxofonGespielt()
{
this.zähler++;
}
public void ausgabe()
{
Console.WriteLine($"{this.zähler} Saxonfon gespielt.");
}
}
}

25
Simpsons/Maggie.cs Normal file
View File

@@ -0,0 +1,25 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
namespace Simpsons
{
internal class Maggie : Familie
{
public Maggie()
{
this.vorname = " Maggie";
}
public void schnullerNuckeln()
{
this.zähler++;
}
public void ausgabe()
{
Console.WriteLine($"{this.zähler} mal am schnuller genuckelt.");
}
}
}

24
Simpsons/Marge.cs Normal file
View File

@@ -0,0 +1,24 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Simpsons
{
internal class Marge : Familie
{
public Marge()
{
this.vorname = " Marge";
}
public void frisörBesuch()
{
this.zähler++;
}
public void ausgabe()
{
Console.WriteLine($"{this.zähler} mal zum Frisör gegangen.");
}
}
}

24
Simpsons/Program.cs Normal file
View File

@@ -0,0 +1,24 @@
namespace Simpsons
{
internal class Program
{
static void Main(string[] args)
{
Familie[] simpsons = new Familie[5];
simpsons[0] = new Homer();
simpsons[1] = new Marge();
simpsons[2] = new Bart();
simpsons[3] = new Lisa();
simpsons[4] = new Maggie();
foreach (Familie item in simpsons)
{
item.vorstellung();
Console.WriteLine();
}
Bart bart = (Bart)simpsons[2];
bart.skateboardGefahren();
}
}
}

10
Simpsons/Simpsons.csproj Normal file
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>

12
SpielAutomat/Automat.cs Normal file
View File

@@ -0,0 +1,12 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace SpielAutomat
{
internal class Automat
{
}
}

10
SpielAutomat/Program.cs Normal file
View File

@@ -0,0 +1,10 @@
namespace SpielAutomat
{
internal class Program
{
static void Main(string[] args)
{
Console.WriteLine("Hello, World!");
}
}
}

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.Diagnostics.Metrics;
namespace SplitCharsIntoCountExtentions
{
internal class Program
{
static void Main(string[] args)
{
string input = "a";
Console.WriteLine($"Word count: {input.CharCount('a')}");
}
}
static class CharCountExtension
{
public static int CharCount(this string input, char letter)
{
int counter = 0;
foreach (var item in input)
{
if (item == letter)
{
counter++;
}
}
return counter;
}
}
}

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,26 @@
using System.Runtime.CompilerServices;
namespace SplitSentencesIntoCountExtentions
{
internal class Program
{
static void Main(string[] args)
{
string input = "Das ist der Versuch nummer 1. Aber das Sagt ja nichts aus selbst wenn es Funktioniert";
Console.WriteLine($"Word count: {input.SentenceCount()}");
}
}
static class SentencesIntoCount
{
public static int SentenceCount(this string input)
{
int freq = 0;
string[] index = input.Split(".");
for (int i = 0; i < index.Length; i++)
{
freq++;
}
return freq;
}
}
}

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,26 @@
using System.Runtime.CompilerServices;
namespace StringCountExtention
{
internal class Program
{
static void Main(string[] args)
{
string input = "Hello World!";
Console.WriteLine($"{input.LeftStringCount(5)}");
Console.WriteLine($"{input.RightStringCount(6)}");
}
}
static class StringCountExtention
{
public static string LeftStringCount(this string input, int frqen)
{
return input.Substring(0, frqen);
}
public static string RightStringCount(this string input, int frqen)
{
return input.Substring(frqen);
}
}
}

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,25 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Intrinsics.X86;
using System.Text;
using System.Threading.Tasks;
namespace Stringaufgabe1
{
internal class CharString
{
private string? _string;
private int _index;
public int CountCharInString(string s, char c)
{
this._string = s;
this._index = _string.Split(c).Length -1;
return _index;
}
public void PrintInfo()
{
Console.WriteLine($"Vorkommende Anzahl: {this._index}");
}
}
}

13
Stringaufgabe1/Program.cs Normal file
View File

@@ -0,0 +1,13 @@
namespace Stringaufgabe1
{
internal class Program
{
static void Main(string[] args)
{
CharString charString = new CharString();
Console.WriteLine("Geben Sie ihren Text ein und dann nach dem buchstaben den Sie zählen wollen: ");
charString.CountCharInString(Console.ReadLine(),Convert.ToChar(Console.ReadLine()));
charString.PrintInfo();
}
}
}

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>

62
Stringaufgabe2/Analyse.cs Normal file
View File

@@ -0,0 +1,62 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Channels;
using System.Threading.Tasks;
namespace Stringaufgabe2
{
internal class Analyse
{
private string? _string;
private char[] konsonant = new char[] { 'b', 'c', 'd', 'f', 'g', 'h', 'j', 'k', 'l', 'm', 'n', 'p', 'q', 'r', 's', 't', 'v', 'w', 'x', 'y', 'z' };
private char[] umlaut = new char[] { 'ä', 'ö', 'ü', 'ß' };
private char[] vokal = new char[] { 'a', 'e', 'i', 'o', 'u' };
private char[] zeichen = new char[] { '.',',',';',':','-','*','#', '+','?','`','´','^','%','!' };
private char[] zahlen = new char[] { '1', '2', '3', '4', '5', '6', '7', '8', '9', '0' };
private int _vokal;
private int _konsonant;
private int _umlaut;
private int _zeichen;
private int _zahlen;
private int _rest;
public void AnalyseString(string s)
{
this._string = s.ToLower();
for (int i = 0; i < _string.Length; i++)
{
if (vokal.Contains(_string[i]))
{
_vokal++;
}
else if (umlaut.Contains(_string[i]))
{
_umlaut++;
}
else if (konsonant.Contains(_string[i]))
{
_konsonant++;
}
else if (zeichen.Contains(_string[i]))
{
_zeichen++;
}
else if (zahlen.Contains(_string[i]))
{
_zahlen++;
}
else
{
_rest++;
}
}
Console.WriteLine($"Der Text hat: {_konsonant} Konsonante");
Console.WriteLine($" {_vokal} Vokale");
Console.WriteLine($" {_umlaut} Umlaute");
Console.WriteLine($" {_zeichen} Zeichen");
Console.WriteLine($" {_zahlen} Zahlen");
Console.WriteLine($" {_rest} Leerzeichen");
}
}
}

12
Stringaufgabe2/Program.cs Normal file
View File

@@ -0,0 +1,12 @@
namespace Stringaufgabe2
{
internal class Program
{
static void Main(string[] args)
{
Analyse analyse = new Analyse();
Console.WriteLine("Geben Sie den zu Prüfenden Text ein: ");
analyse.AnalyseString(Console.ReadLine());
}
}
}

Some files were not shown because too many files have changed in this diff Show More