Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Uwe Wienkop
Prog1_WS2018_19_Wienkop
Commits
c42eccb3
Commit
c42eccb3
authored
Nov 28, 2018
by
Uwe Wienkop
Browse files
Ende Woche 08 (Klassen, Properties, static)
parent
a5cec928
Changes
13
Hide whitespace changes
Inline
Side-by-side
01Pythagoras/08PraktikumVereinIntro/08PraktikumVereinIntro.csproj
0 → 100644
View file @
c42eccb3
<?xml version="1.0" encoding="utf-8"?>
<Project
ToolsVersion=
"15.0"
xmlns=
"http://schemas.microsoft.com/developer/msbuild/2003"
>
<Import
Project=
"$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props"
Condition=
"Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')"
/>
<PropertyGroup>
<Configuration
Condition=
" '$(Configuration)' == '' "
>
Debug
</Configuration>
<Platform
Condition=
" '$(Platform)' == '' "
>
AnyCPU
</Platform>
<ProjectGuid>
{B958682D-7FC0-473B-8746-60B5371CF26F}
</ProjectGuid>
<OutputType>
Exe
</OutputType>
<RootNamespace>
_08PraktikumVereinIntro
</RootNamespace>
<AssemblyName>
08PraktikumVereinIntro
</AssemblyName>
<TargetFrameworkVersion>
v4.6.1
</TargetFrameworkVersion>
<FileAlignment>
512
</FileAlignment>
<AutoGenerateBindingRedirects>
true
</AutoGenerateBindingRedirects>
<Deterministic>
true
</Deterministic>
</PropertyGroup>
<PropertyGroup
Condition=
" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "
>
<PlatformTarget>
AnyCPU
</PlatformTarget>
<DebugSymbols>
true
</DebugSymbols>
<DebugType>
full
</DebugType>
<Optimize>
false
</Optimize>
<OutputPath>
bin\Debug\
</OutputPath>
<DefineConstants>
DEBUG;TRACE
</DefineConstants>
<ErrorReport>
prompt
</ErrorReport>
<WarningLevel>
4
</WarningLevel>
</PropertyGroup>
<PropertyGroup
Condition=
" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "
>
<PlatformTarget>
AnyCPU
</PlatformTarget>
<DebugType>
pdbonly
</DebugType>
<Optimize>
true
</Optimize>
<OutputPath>
bin\Release\
</OutputPath>
<DefineConstants>
TRACE
</DefineConstants>
<ErrorReport>
prompt
</ErrorReport>
<WarningLevel>
4
</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference
Include=
"System"
/>
<Reference
Include=
"System.Core"
/>
<Reference
Include=
"System.Xml.Linq"
/>
<Reference
Include=
"System.Data.DataSetExtensions"
/>
<Reference
Include=
"Microsoft.CSharp"
/>
<Reference
Include=
"System.Data"
/>
<Reference
Include=
"System.Net.Http"
/>
<Reference
Include=
"System.Xml"
/>
</ItemGroup>
<ItemGroup>
<Compile
Include=
"Mitglied.cs"
/>
<Compile
Include=
"Program.cs"
/>
<Compile
Include=
"Properties\AssemblyInfo.cs"
/>
<Compile
Include=
"Verein.cs"
/>
</ItemGroup>
<ItemGroup>
<None
Include=
"App.config"
/>
</ItemGroup>
<Import
Project=
"$(MSBuildToolsPath)\Microsoft.CSharp.targets"
/>
</Project>
\ No newline at end of file
01Pythagoras/08PraktikumVereinIntro/App.config
0 → 100644
View file @
c42eccb3
<?
xml
version
=
"1.0"
encoding
=
"utf-8"
?>
<
configuration
>
<
startup
>
<
supportedRuntime
version
=
"v4.0"
sku
=
".NETFramework,Version=v4.6.1"
/>
</
startup
>
</
configuration
>
\ No newline at end of file
01Pythagoras/08PraktikumVereinIntro/Mitglied.cs
0 → 100644
View file @
c42eccb3
namespace
_08PraktikumVereinIntro
{
internal
class
Mitglied
{
private
string
name
;
private
int
v2
;
private
string
v3
;
public
Mitglied
(
string
v1
,
int
v2
,
string
v3
)
{
this
.
name
=
v1
;
this
.
v2
=
v2
;
this
.
v3
=
v3
;
}
}
}
\ No newline at end of file
01Pythagoras/08PraktikumVereinIntro/Program.cs
0 → 100644
View file @
c42eccb3
using
System
;
using
System.Collections.Generic
;
using
System.Linq
;
using
System.Text
;
using
System.Threading.Tasks
;
namespace
_08PraktikumVereinIntro
{
class
Program
{
static
void
Main
(
string
[]
args
)
{
// Kommentieren Sie zunächst alles aus, was Sie noch nicht implementiert haben
// und arbeiten Sie sich schrittweise vor
Mitglied
p1
=
new
Mitglied
(
"Kai Pirinha"
,
1993
,
"kaipi@friends.com"
);
Mitglied
p2
=
new
Mitglied
(
"Bilbo Buggins"
);
p2
.
Email
=
"bb@freebee.com"
;
Mitglied
p3
=
new
Mitglied
(
"Sam Gamgee"
,
2001
);
Mitglied
p4
=
new
Mitglied
(
"Pina Kolada"
,
1999
);
Mitglied
p5
=
new
Mitglied
(
"Galadriel"
,
1990
);
Mitglied
p6
=
new
Mitglied
(
"Kati Kapinski"
);
Mitglied
p7
=
new
Mitglied
(
"Dana Scully"
,
1980
,
"danny@thn.edu"
);
Mitglied
p8
=
new
Mitglied
(
"James T. Kirk"
,
1993
);
Verein
v1
=
new
Verein
(
"Freunde von Pi"
,
p1
,
p2
,
p3
,
p4
,
p5
,
p6
,
p7
,
p8
);
Console
.
WriteLine
(
v1
);
Console
.
WriteLine
(
"\nMitglieder mit Pi:"
);
v1
.
EnthaeltPi
();
Console
.
WriteLine
(
"\nAlter Hase: "
+
v1
.
AlterHase
());
Console
.
WriteLine
(
"\nSuche(Galadriel): "
+
v1
.
Suche
(
"Galadriel"
));
Mitglied
[]
personen
=
new
Mitglied
[
4
];
personen
[
0
]
=
new
Mitglied
(
"Kai Pirinha"
);
personen
[
1
]
=
new
Mitglied
(
"Dana Scully"
,
1990
);
personen
[
2
]
=
new
Mitglied
(
"Jean-Luc Skywalker"
,
1950
);
personen
[
3
]
=
new
Mitglied
(
"Luke Picard"
);
Verein
v2
=
new
Verein
(
"Freunde von Pu"
,
personen
);
Console
.
WriteLine
();
Console
.
WriteLine
(
v2
);
Console
.
WriteLine
(
"\nSchnittmenge:"
);
Verein
.
Schnittmenge
(
v1
,
v2
);
// Ungültige Jahresangaben
Console
.
WriteLine
();
try
{
Mitglied
p
=
new
Mitglied
(
"Betty Rourke"
,
1905
);
Console
.
WriteLine
(
"Diese Code-Zeile darf wg. ungültigem Jahr nicht erreicht werden!"
);
}
catch
(
Exception
e
)
{
Console
.
WriteLine
(
"Exception korrekt generiert:\n"
+
e
.
Message
);
}
Console
.
WriteLine
();
try
{
Mitglied
p
=
new
Mitglied
(
"Betty Rourke"
);
p
.
Eintrittsjahr
=
1905
;
Console
.
WriteLine
(
"Diese Code-Zeile darf wg. ungültigem Jahr nicht erreicht werden!"
);
}
catch
(
Exception
e
)
{
Console
.
WriteLine
(
"Exception korrekt generiert:\n"
+
e
.
Message
);
}
}
}
//class Mitglied
//{
// string name;
// int eintrittsjahr;
// public Mitglied(string Name, int Eintrittsjahr=int.MinValue)
// {
// if (Eintrittsjahr == int.MinValue)
// Eintrittsjahr = DateTime.Now.Year;
// else
// if (Eintrittsjahr < 1950 || Eintrittsjahr > DateTime.Now.Year)
// throw new ArgumentOutOfRangeException("Ungültiges Jahr");
// eintrittsjahr = Eintrittsjahr;
// name = Name;
// }
//}
//class Verein
//{
// private string v;
// private Mitglied[] mitglieder;
// public Verein(string name, params Mitglied[] Mitglieder)
// {
// v = name;
// mitglieder = Mitglieder;
// }
// public override string ToString()
// {
// string erg = "";
// foreach (Mitglied m in mitglieder)
// {
// erg += m.ToString() + '\n';
// }
// return erg;
// }
//}
}
01Pythagoras/08PraktikumVereinIntro/Properties/AssemblyInfo.cs
0 → 100644
View file @
c42eccb3
using
System.Reflection
;
using
System.Runtime.CompilerServices
;
using
System.Runtime.InteropServices
;
// Allgemeine Informationen über eine Assembly werden über die folgenden
// Attribute gesteuert. Ändern Sie diese Attributwerte, um die Informationen zu ändern,
// die einer Assembly zugeordnet sind.
[
assembly
:
AssemblyTitle
(
"08PraktikumVereinIntro"
)]
[
assembly
:
AssemblyDescription
(
""
)]
[
assembly
:
AssemblyConfiguration
(
""
)]
[
assembly
:
AssemblyCompany
(
""
)]
[
assembly
:
AssemblyProduct
(
"08PraktikumVereinIntro"
)]
[
assembly
:
AssemblyCopyright
(
"Copyright © 2018"
)]
[
assembly
:
AssemblyTrademark
(
""
)]
[
assembly
:
AssemblyCulture
(
""
)]
// Durch Festlegen von ComVisible auf FALSE werden die Typen in dieser Assembly
// für COM-Komponenten unsichtbar. Wenn Sie auf einen Typ in dieser Assembly von
// COM aus zugreifen müssen, sollten Sie das ComVisible-Attribut für diesen Typ auf "True" festlegen.
[
assembly
:
ComVisible
(
false
)]
// Die folgende GUID bestimmt die ID der Typbibliothek, wenn dieses Projekt für COM verfügbar gemacht wird
[
assembly
:
Guid
(
"b958682d-7fc0-473b-8746-60b5371cf26f"
)]
// Versionsinformationen für eine Assembly bestehen aus den folgenden vier Werten:
//
// Hauptversion
// Nebenversion
// Buildnummer
// Revision
//
// Sie können alle Werte angeben oder Standardwerte für die Build- und Revisionsnummern verwenden,
// übernehmen, indem Sie "*" eingeben:
// [assembly: AssemblyVersion("1.0.*")]
[
assembly
:
AssemblyVersion
(
"1.0.0.0"
)]
[
assembly
:
AssemblyFileVersion
(
"1.0.0.0"
)]
01Pythagoras/08PraktikumVereinIntro/Verein.cs
0 → 100644
View file @
c42eccb3
namespace
_08PraktikumVereinIntro
{
internal
class
Verein
{
private
string
v
;
private
Mitglied
p1
;
private
Mitglied
p2
;
private
Mitglied
p3
;
private
Mitglied
p4
;
private
Mitglied
p5
;
private
Mitglied
p6
;
private
Mitglied
p7
;
private
Mitglied
p8
;
public
Verein
(
string
v
,
Mitglied
p1
,
Mitglied
p2
,
Mitglied
p3
,
Mitglied
p4
,
Mitglied
p5
,
Mitglied
p6
,
Mitglied
p7
,
Mitglied
p8
)
{
this
.
v
=
v
;
this
.
p1
=
p1
;
this
.
p2
=
p2
;
this
.
p3
=
p3
;
this
.
p4
=
p4
;
this
.
p5
=
p5
;
this
.
p6
=
p6
;
this
.
p7
=
p7
;
this
.
p8
=
p8
;
}
}
}
\ No newline at end of file
01Pythagoras/Prog1_WS2018.sln
View file @
c42eccb3
...
...
@@ -65,6 +65,10 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "07KlassenIntro", "..\07Klas
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "08KlassenIntro2", "..\08KlassenIntro2\08KlassenIntro2.csproj", "{6047172E-53BD-4B4A-BDC4-A60A5BBAAC23}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "08PraktikumVereinIntro", "08PraktikumVereinIntro\08PraktikumVereinIntro.csproj", "{B958682D-7FC0-473B-8746-60B5371CF26F}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "08Handy", "..\08Handy\08Handy.csproj", "{50173EB3-3D6F-4364-931F-5A22AA6B9B27}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
...
...
@@ -195,6 +199,14 @@ Global
{6047172E-53BD-4B4A-BDC4-A60A5BBAAC23}.Debug|Any CPU.Build.0 = Debug|Any CPU
{6047172E-53BD-4B4A-BDC4-A60A5BBAAC23}.Release|Any CPU.ActiveCfg = Release|Any CPU
{6047172E-53BD-4B4A-BDC4-A60A5BBAAC23}.Release|Any CPU.Build.0 = Release|Any CPU
{B958682D-7FC0-473B-8746-60B5371CF26F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{B958682D-7FC0-473B-8746-60B5371CF26F}.Debug|Any CPU.Build.0 = Debug|Any CPU
{B958682D-7FC0-473B-8746-60B5371CF26F}.Release|Any CPU.ActiveCfg = Release|Any CPU
{B958682D-7FC0-473B-8746-60B5371CF26F}.Release|Any CPU.Build.0 = Release|Any CPU
{50173EB3-3D6F-4364-931F-5A22AA6B9B27}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{50173EB3-3D6F-4364-931F-5A22AA6B9B27}.Debug|Any CPU.Build.0 = Debug|Any CPU
{50173EB3-3D6F-4364-931F-5A22AA6B9B27}.Release|Any CPU.ActiveCfg = Release|Any CPU
{50173EB3-3D6F-4364-931F-5A22AA6B9B27}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
...
...
06TicTacToe_Intro/Program.cs
View file @
c42eccb3
...
...
@@ -26,10 +26,11 @@ namespace _06TicTacToe_Intro
}
return
true
;
}
static
bool
TicTacToeTest
(
int
[,]
spielbrett
,
int
x
,
int
y
,
static
bool
TicTacToeTest
(
int
[,]
spielbrett
,
int
z
,
int
s
,
int
zOff1
,
int
sOff1
,
int
zOff2
,
int
sOff2
)
{
return
true
;
if
(
z
+
zOff1
<
0
||
z
+
zOff1
>=
spielbrett
.
GetLength
(
0
))
return
false
;
}
static
void
Main
(
string
[]
args
)
...
...
@@ -58,6 +59,7 @@ namespace _06TicTacToe_Intro
SpielfeldAusgeben
(
spielfeld
);
EingabeSpieler
(
1
,
zeilenAnzahl
,
spaltenAnzahl
,
out
zeile
,
out
spalte
);
spielfeld
[
zeile
,
spalte
]
=
1
;
TicTacToeTest
()
SpielfeldAusgeben
(
spielfeld
);
EingabeSpieler
(
2
,
zeilenAnzahl
,
spaltenAnzahl
,
out
zeile
,
out
spalte
);
...
...
08Handy/08Handy.csproj
0 → 100644
View file @
c42eccb3
<?xml version="1.0" encoding="utf-8"?>
<Project
ToolsVersion=
"15.0"
xmlns=
"http://schemas.microsoft.com/developer/msbuild/2003"
>
<Import
Project=
"$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props"
Condition=
"Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')"
/>
<PropertyGroup>
<Configuration
Condition=
" '$(Configuration)' == '' "
>
Debug
</Configuration>
<Platform
Condition=
" '$(Platform)' == '' "
>
AnyCPU
</Platform>
<ProjectGuid>
{50173EB3-3D6F-4364-931F-5A22AA6B9B27}
</ProjectGuid>
<OutputType>
Exe
</OutputType>
<RootNamespace>
_08Handy
</RootNamespace>
<AssemblyName>
08Handy
</AssemblyName>
<TargetFrameworkVersion>
v4.6.1
</TargetFrameworkVersion>
<FileAlignment>
512
</FileAlignment>
<AutoGenerateBindingRedirects>
true
</AutoGenerateBindingRedirects>
<Deterministic>
true
</Deterministic>
</PropertyGroup>
<PropertyGroup
Condition=
" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "
>
<PlatformTarget>
AnyCPU
</PlatformTarget>
<DebugSymbols>
true
</DebugSymbols>
<DebugType>
full
</DebugType>
<Optimize>
false
</Optimize>
<OutputPath>
bin\Debug\
</OutputPath>
<DefineConstants>
DEBUG;TRACE
</DefineConstants>
<ErrorReport>
prompt
</ErrorReport>
<WarningLevel>
4
</WarningLevel>
</PropertyGroup>
<PropertyGroup
Condition=
" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "
>
<PlatformTarget>
AnyCPU
</PlatformTarget>
<DebugType>
pdbonly
</DebugType>
<Optimize>
true
</Optimize>
<OutputPath>
bin\Release\
</OutputPath>
<DefineConstants>
TRACE
</DefineConstants>
<ErrorReport>
prompt
</ErrorReport>
<WarningLevel>
4
</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference
Include=
"System"
/>
<Reference
Include=
"System.Core"
/>
<Reference
Include=
"System.Xml.Linq"
/>
<Reference
Include=
"System.Data.DataSetExtensions"
/>
<Reference
Include=
"Microsoft.CSharp"
/>
<Reference
Include=
"System.Data"
/>
<Reference
Include=
"System.Net.Http"
/>
<Reference
Include=
"System.Xml"
/>
</ItemGroup>
<ItemGroup>
<Compile
Include=
"Program.cs"
/>
<Compile
Include=
"Properties\AssemblyInfo.cs"
/>
</ItemGroup>
<ItemGroup>
<None
Include=
"App.config"
/>
</ItemGroup>
<Import
Project=
"$(MSBuildToolsPath)\Microsoft.CSharp.targets"
/>
</Project>
\ No newline at end of file
08Handy/App.config
0 → 100644
View file @
c42eccb3
<?
xml
version
=
"1.0"
encoding
=
"utf-8"
?>
<
configuration
>
<
startup
>
<
supportedRuntime
version
=
"v4.0"
sku
=
".NETFramework,Version=v4.6.1"
/>
</
startup
>
</
configuration
>
\ No newline at end of file
08Handy/Program.cs
0 → 100644
View file @
c42eccb3
using
System
;
using
System.Collections.Generic
;
using
System.Linq
;
using
System.Text
;
using
System.Threading.Tasks
;
namespace
_08Handy
{
class
Handy
{
string
besitzer
;
int
seriennummer
;
// NICHT STATIC Klassenvariable:
// - je (Handy-) Objekt
// - Jedes Handy hat einen Besitzer und eine Seriennummer
static
int
naechsteSeriennummer
=
1
;
// Static Klassenvariable:
// - Nur EINMAL pro Klasse
// - Die Klasse hat zusätzlich eine letzteSeriennummer
//public void ErhoeheSeriennummer()
//{
// naechsteSeriennummer++;
//}
public
Handy
(
string
Besitzer
)
{
besitzer
=
Besitzer
;
seriennummer
=
naechsteSeriennummer
;
naechsteSeriennummer
++;
}
// STATIC Bei Methoden:
// - Es wird keine Objektreferenz benötigt
public
static
void
SetzeSeriennummer
(
int
Wert
)
{
if
(
Wert
>
naechsteSeriennummer
)
naechsteSeriennummer
=
Wert
;
else
throw
new
ArgumentException
(
"Seriennummer muss aufsteigend sein"
);
}
public
override
string
ToString
()
{
return
$"Handy:
{
besitzer
}
, Ser.Nr.:
{
seriennummer
}
"
;
}
}
class
Program
{
static
void
Main
(
string
[]
args
)
{
Handy
.
SetzeSeriennummer
(
1000
);
Handy
h1
=
new
Handy
(
"Anton"
);
//h1.ErhoeheSeriennummer();
Handy
h2
=
new
Handy
(
"Berta"
);
//h1.ErhoeheSeriennummer();
Handy
h3
=
new
Handy
(
"Claudia"
);
Console
.
WriteLine
(
h1
);
Console
.
WriteLine
(
h2
);
Console
.
WriteLine
(
h3
);
}
}
}
08Handy/Properties/AssemblyInfo.cs
0 → 100644
View file @
c42eccb3
using
System.Reflection
;
using
System.Runtime.CompilerServices
;
using
System.Runtime.InteropServices
;
// Allgemeine Informationen über eine Assembly werden über die folgenden
// Attribute gesteuert. Ändern Sie diese Attributwerte, um die Informationen zu ändern,
// die einer Assembly zugeordnet sind.
[
assembly
:
AssemblyTitle
(
"08Handy"
)]
[
assembly
:
AssemblyDescription
(
""
)]
[
assembly
:
AssemblyConfiguration
(
""
)]
[
assembly
:
AssemblyCompany
(
""
)]
[
assembly
:
AssemblyProduct
(
"08Handy"
)]
[
assembly
:
AssemblyCopyright
(
"Copyright © 2018"
)]
[
assembly
:
AssemblyTrademark
(
""
)]
[
assembly
:
AssemblyCulture
(
""
)]
// Durch Festlegen von ComVisible auf FALSE werden die Typen in dieser Assembly
// für COM-Komponenten unsichtbar. Wenn Sie auf einen Typ in dieser Assembly von
// COM aus zugreifen müssen, sollten Sie das ComVisible-Attribut für diesen Typ auf "True" festlegen.
[
assembly
:
ComVisible
(
false
)]
// Die folgende GUID bestimmt die ID der Typbibliothek, wenn dieses Projekt für COM verfügbar gemacht wird
[
assembly
:
Guid
(
"50173eb3-3d6f-4364-931f-5a22aa6b9b27"
)]
// Versionsinformationen für eine Assembly bestehen aus den folgenden vier Werten:
//
// Hauptversion
// Nebenversion
// Buildnummer
// Revision
//
// Sie können alle Werte angeben oder Standardwerte für die Build- und Revisionsnummern verwenden,
// übernehmen, indem Sie "*" eingeben:
// [assembly: AssemblyVersion("1.0.*")]
[
assembly
:
AssemblyVersion
(
"1.0.0.0"
)]
[
assembly
:
AssemblyFileVersion
(
"1.0.0.0"
)]
08KlassenIntro2/Program.cs
View file @
c42eccb3
...
...
@@ -15,29 +15,61 @@ namespace _08KlassenIntro2
int
alter
;
// Konstruktor: Initialisiert das Objekt; Wertebereichsprüfung, Umrechnung
public
Person
(
string
Vorname
,
string
Name
,
int
Alter
)
public
Person
(
string
Vorname
,
string
Name
=
null
,
int
Alter
=
0
)
{
if
(
Alter
<
0
||
Alter
>
125
)
throw
new
ArgumentOutOfRangeException
(
"Alter muss im Bereich von 0 .. 125 sein"
);
vorname
=
Vorname
;
name
=
Name
;
alter
=
Alter
;
}
public
Person
(
string
Vorname
)
{
vorname
=
Vorname
;
alter
=
-
1
;
}
public
void
DruckePerson
()
{
Console
.
WriteLine
(
$"Name:
{
name
}
, Vorname:
{
vorname
}
"
);
}
public
override
string
ToString
()
//public override string ToString()
//{
// return $"{name}, {vorname}";
//}
public
override
string
ToString
()
=>
$"
{
name
}
,
{
vorname
}
"
;
public
int
getAlter
()
{
return
alter
;
}
public
void
setAlter
(
int
value
)
{
alter
=
value
;
}
public
int
Alter
{
return
$"
{
name
}
,
{
vorname
}
"
;
get
{
Console
.
WriteLine
(
$"get-Aufruf von Alter =>
{
alter
}
"
);
return
alter
;
}
set
{
Console
.
WriteLine
(
$"set-Aufruf von Alter <=
{
value
}
"
);
alter
=
value
;
}
}
public
string
getName
()
{
return
name
;
}
public
string
Name
{
get
{
return
name
;
}
}
public
void
setName
(
string
Wert
)
{
name
=
Wert
;
}
public
string
Name
{
get
=>
name
;
set
{
if
(
value
!=
""
)
name
=
value
;
else
throw
new
ArgumentException
(
"Leerer Name ist nicht zulässig"
);
}
}
}
class
Program
{
...
...
@@ -46,13 +78,21 @@ namespace _08KlassenIntro2
Person
anton
=
new
Person
(
"Anton"
,
"Meier"
,
50
);
//anton.name = "Meier";
//anton.vorname = "Anton";
Person
berta
=
new
Person
(
"Berta"
);
anton
.
DruckePerson
();
Console
.
WriteLine
(
anton
);
//Person berta = new Person("Berta");
//anton.DruckePerson();
//Console.WriteLine(anton);
//string person = anton.ToString();
//string name = anton.getName();
//name = anton.Name;
//anton.Name = "Xaver";
//anton.setAlter(anton.getAlter() + 1);
anton
.
Alter
++;
anton
.
Alter
=
15
;
anton
.
Alter
+=
1
;
string
person
=
anton
.
ToString
();
string
name
=
anton
.
getName
();
name
=
anton
.
Name
;
}
}
}
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment