73 lines
1.5 KiB
C#
73 lines
1.5 KiB
C#
|
|
|
|
using Ubung;
|
|
|
|
// Übung 1
|
|
Limousine limousine = new(4);
|
|
Kombi kombi = new();
|
|
Van van = new();
|
|
|
|
// Übung 3
|
|
var gentec = new GenTec<int>(5);
|
|
gentec.SetValue(3, 245);
|
|
gentec.SetValue(2, 45);
|
|
gentec.SetValue(1, 11);
|
|
gentec.SetValue(4, 34);
|
|
gentec.SetValue(0, 56);
|
|
|
|
Console.WriteLine(gentec.GetType());
|
|
Console.WriteLine(gentec.GetValue(4));
|
|
|
|
var gen = new GenTec<double>(5);
|
|
gen.SetValue(3, 245);
|
|
gen.SetValue(2, 45);
|
|
gen.SetValue(1, 11);
|
|
gen.SetValue(4, 34.9123);
|
|
gen.SetValue(0, 56);
|
|
|
|
Console.WriteLine(gen.GetType());
|
|
Console.WriteLine(gen.GetValue(4));
|
|
|
|
var genList = new GenTecList<int>();
|
|
genList.AddValue(245);
|
|
genList.AddValue(3);
|
|
genList.AddValue(25);
|
|
genList.AddValue(24);
|
|
|
|
Console.WriteLine(genList.GetType());
|
|
Console.WriteLine(genList.GetValue(0));
|
|
|
|
var genList2 = new GenTecList<int>();
|
|
genList2.AddValue(245);
|
|
genList2.AddValue(3);
|
|
genList2.AddValue(25);
|
|
genList2.AddValue(24);
|
|
|
|
Console.WriteLine(genList2.GetType());
|
|
Console.WriteLine(genList2.GetValue(1));
|
|
|
|
// Übung 4
|
|
var rand = new Random();
|
|
List<int> list = new();
|
|
|
|
for (int i = 0; i < 100; i++)
|
|
{
|
|
list.Add(rand.Next(101));
|
|
}
|
|
|
|
var anzahl = list.Count(o => o < list.Average());
|
|
Console.WriteLine(anzahl);
|
|
|
|
|
|
var rooms = new Dictionary<string, string[]>
|
|
{
|
|
{ "618", new [] { "Tim", "Ute"} },
|
|
{ "621", new [] { "Hans", "Jakob"} },
|
|
};
|
|
|
|
Console.WriteLine(SearchStudent(rooms, "Jakob"));
|
|
|
|
string SearchStudent(Dictionary<string, string[]> studentInClasses, string student)
|
|
{
|
|
return studentInClasses.First(o => o.Value.Contains(student)).Key;
|
|
} |