Commit e16f748b authored by Uwe Wienkop's avatar Uwe Wienkop

2020-01-07

parent 5145981c
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp3.1</TargetFramework>
<RootNamespace>_12DiesUndDas</RootNamespace>
</PropertyGroup>
</Project>
using System;
namespace _12DiesUndDas
{
class Person
{
public string name; // name kommt pro Personenobj. vor
readonly int persId; // persID kommt pro Personenobj. vor
static int naechsteID = 1; // static-Datenfelder kommen nur
// EINMAL PRO KLASSE vor
static Person[] pFeld = new Person[1000];
public Person(string name)
{
this.name = name;
persId = naechsteID;
pFeld[naechsteID - 1] = this; // this ~ das gesamte aktuelle Objekt
naechsteID++;
}
}
class Program
{
static int Suchen(int[] f, int zahl)
{
for (int i = 0; i < f.Length; i++)
{
if (f[i] == zahl)
return i;
}
return -1;
}
static int[] SucheAlle(int[] f, int zahl)
{
int anz = 0;
for (int i = 0; i < f.Length; i++)
{
if (f[i] == zahl)
anz++;
}
if (anz == 0)
return null;
int[] fInd = new int[anz];
anz = 0;
for (int i = 0; i < f.Length; i++)
{
if (f[i] == zahl)
{
fInd[anz] = i;
anz++;
}
}
return fInd;
}
static Person SuchePerson(Person[] f, Person gesucht)
{
for (int i = 0; i < f.Length; i++)
{
if (f[i].name == gesucht.name) // Vergleich zweier Referenzen
return f[i];
}
return null;
}
static void Main(string[] args)
{
char[] sep = { ' ', '!' };
string s = "Hello World! Alles Gute für das neue Jahr";
string[] woerter = s.Split(sep, StringSplitOptions.RemoveEmptyEntries);
foreach (string item in woerter)
{
Console.WriteLine($">{item}<");
}
Console.WriteLine($">{s.Substring(6, 5)}<");
Console.WriteLine($">{s.Substring(6)}<");
int[] f = { 2, 4, 5, 8, 9, 10, 15, 12, 2, 3 };
int zahl = 2;
int ind = -1;
for (int i = 0; i < f.Length; i++)
{
if (f[i] == zahl)
{
ind = i;
break;
}
}
if (ind != -1)
Console.WriteLine($"Gefunden an Pos {ind}");
else
Console.WriteLine("Nicht gefunden!");
Person[] persFeld = new Person[3];
persFeld[0] = new Person("Anton" );
persFeld[1] = new Person("Berta" );
persFeld[2] = new Person("Claudia");
Person gesuchtePerson = new Person("Anton" );
Person p = SuchePerson(persFeld, gesuchtePerson);
if (p == null)
Console.WriteLine("Die Person kommt im Feld nicht vor");
else
Console.WriteLine("Kommt vor!");
}
}
}
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp3.1</TargetFramework>
<RootNamespace>_12Speisekarte</RootNamespace>
</PropertyGroup>
</Project>
using System;
using System.IO;
namespace _12Speisekarte
{
class Program
{
static void Main(string[] args)
{
StreamReader sr = new StreamReader(@"..\..\..\Speisekarte.txt");
while (!sr.EndOfStream)
{
//Console.WriteLine(sr.ReadLine());
string zeile = sr.ReadLine();
string[] daten = zeile.Split(';');
double preis = Convert.ToDouble(daten[2]);
Console.WriteLine($"Kürzel: {daten[0]}, Text: {daten[1],40}, Preis: {preis,10:f2}");
}
sr.Close();
}
}
}
S1;Peking Suppe;3,00
S2;Miso Suppe;2,90
V1;Frühlingsrolle;3,10
V2;Krabbenchips (Krupuk);2,80
V3;Gemischter Salat;3,30
H1;Gebratene Nudeln mit Gemüse;8,50
H2;Nasi-Goreng;10,80
H3;Hühnerfleisch Chop-Suey;9,50
H4;Schweinefleisch süß-sauer;10,00
H5;Rindfleisch Gong-Bao;11,50
H6;Ente mit Gemüse;12,50
D1;Gebackene Banane mit Honig;3,00
D2;Frisches Obst;2,50
......@@ -97,10 +97,14 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "11Switch", "11Switch\11Swit
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "11UebungMo", "11UebungMo\11UebungMo.csproj", "{3C4139B9-F809-4B18-B4BA-3DFC23DDACFD}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "11KlasseBug", "11KlasseBug\11KlasseBug.csproj", "{824002E3-C7B2-47A6-9306-65A52FFADA5D}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "11KlasseBug", "11KlasseBug\11KlasseBug.csproj", "{824002E3-C7B2-47A6-9306-65A52FFADA5D}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "11WPFDemo", "11WPFDemo\11WPFDemo.csproj", "{C04747AC-2F30-40F2-9B27-197259FACAF6}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "12DiesUndDas", "12DiesUndDas\12DiesUndDas.csproj", "{946601F3-87FE-4861-BEE6-A04D3B385F1B}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "12Speisekarte", "12Speisekarte\12Speisekarte.csproj", "{F6CC9544-5B04-45F0-8452-E23C24A86710}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
......@@ -303,6 +307,14 @@ Global
{C04747AC-2F30-40F2-9B27-197259FACAF6}.Debug|Any CPU.Build.0 = Debug|Any CPU
{C04747AC-2F30-40F2-9B27-197259FACAF6}.Release|Any CPU.ActiveCfg = Release|Any CPU
{C04747AC-2F30-40F2-9B27-197259FACAF6}.Release|Any CPU.Build.0 = Release|Any CPU
{946601F3-87FE-4861-BEE6-A04D3B385F1B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{946601F3-87FE-4861-BEE6-A04D3B385F1B}.Debug|Any CPU.Build.0 = Debug|Any CPU
{946601F3-87FE-4861-BEE6-A04D3B385F1B}.Release|Any CPU.ActiveCfg = Release|Any CPU
{946601F3-87FE-4861-BEE6-A04D3B385F1B}.Release|Any CPU.Build.0 = Release|Any CPU
{F6CC9544-5B04-45F0-8452-E23C24A86710}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{F6CC9544-5B04-45F0-8452-E23C24A86710}.Debug|Any CPU.Build.0 = Debug|Any CPU
{F6CC9544-5B04-45F0-8452-E23C24A86710}.Release|Any CPU.ActiveCfg = Release|Any CPU
{F6CC9544-5B04-45F0-8452-E23C24A86710}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment