Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
O
OOP2024-AMP
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Package Registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Uwe Wienkop
OOP2024-AMP
Commits
555ebccb
Commit
555ebccb
authored
11 months ago
by
Uwe Wienkop
Browse files
Options
Downloads
Patches
Plain Diff
Indexer + Operatorüberladung
parent
dc799add
No related branches found
No related tags found
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
OOP2024_AMP.sln
+6
-0
6 additions, 0 deletions
OOP2024_AMP.sln
P03 Klassen/Buergeramt.cs
+53
-0
53 additions, 0 deletions
P03 Klassen/Buergeramt.cs
P03 Klassen/Perso.cs
+1
-1
1 addition, 1 deletion
P03 Klassen/Perso.cs
P03 Klassen/Program.cs
+6
-1
6 additions, 1 deletion
P03 Klassen/Program.cs
with
66 additions
and
2 deletions
OOP2024_AMP.sln
+
6
−
0
View file @
555ebccb
...
@@ -11,6 +11,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "P02 Methoden", "P02 Methode
...
@@ -11,6 +11,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "P02 Methoden", "P02 Methode
EndProject
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "P03 Klassen", "P03 Klassen\P03 Klassen.csproj", "{E0E52007-EEDB-4075-9371-909D9E435F61}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "P03 Klassen", "P03 Klassen\P03 Klassen.csproj", "{E0E52007-EEDB-4075-9371-909D9E435F61}"
EndProject
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "P04 Brueche", "..\P04 Brueche\P04 Brueche.csproj", "{09DFCE5C-70A6-42AA-88E8-AB643EE5E790}"
EndProject
Global
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Debug|Any CPU = Debug|Any CPU
...
@@ -33,6 +35,10 @@ Global
...
@@ -33,6 +35,10 @@ Global
{E0E52007-EEDB-4075-9371-909D9E435F61}.Debug|Any CPU.Build.0 = Debug|Any CPU
{E0E52007-EEDB-4075-9371-909D9E435F61}.Debug|Any CPU.Build.0 = Debug|Any CPU
{E0E52007-EEDB-4075-9371-909D9E435F61}.Release|Any CPU.ActiveCfg = Release|Any CPU
{E0E52007-EEDB-4075-9371-909D9E435F61}.Release|Any CPU.ActiveCfg = Release|Any CPU
{E0E52007-EEDB-4075-9371-909D9E435F61}.Release|Any CPU.Build.0 = Release|Any CPU
{E0E52007-EEDB-4075-9371-909D9E435F61}.Release|Any CPU.Build.0 = Release|Any CPU
{09DFCE5C-70A6-42AA-88E8-AB643EE5E790}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{09DFCE5C-70A6-42AA-88E8-AB643EE5E790}.Debug|Any CPU.Build.0 = Debug|Any CPU
{09DFCE5C-70A6-42AA-88E8-AB643EE5E790}.Release|Any CPU.ActiveCfg = Release|Any CPU
{09DFCE5C-70A6-42AA-88E8-AB643EE5E790}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
HideSolutionNode = FALSE
...
...
This diff is collapsed.
Click to expand it.
P03 Klassen/Buergeramt.cs
0 → 100644
+
53
−
0
View file @
555ebccb
using
System
;
using
System.Collections.Generic
;
using
System.Linq
;
using
System.Text
;
using
System.Threading.Tasks
;
namespace
P03_Klassen
{
class
Buergeramt
{
int
maxPersonalausweise
;
int
naechstePersoPos
=
0
;
// nicht-static, da unterschiedliche Städte
Perso
[]
persos
;
public
Buergeramt
(
int
maxPersos
)
{
maxPersonalausweise
=
maxPersos
;
persos
=
new
Perso
[
maxPersonalausweise
];
}
public
Perso
NeuerPersonalausweis
(
string
name
,
int
alter
)
{
Perso
neuerPerso
=
new
Perso
(
name
,
alter
);
persos
[
naechstePersoPos
]
=
neuerPerso
;
naechstePersoPos
++;
// Test, ob Feldüberlauf ...
return
neuerPerso
;
}
public
Perso
this
[
int
index
]
{
get
{
if
(
index
>=
0
&&
index
<
naechstePersoPos
)
return
persos
[
index
];
else
throw
new
IndexOutOfRangeException
(
"Ungültiger Index"
);
}
// ggf. auch set oder private set
}
// public string this[int index] geht nicht, da
// der Returntyp nicht beim Überladen berücksichtigt wird
public
Perso
this
[
string
name
]
{
get
{
for
(
int
index
=
0
;
index
<
maxPersonalausweise
;
index
++
)
if
(
persos
[
index
]?.
Name
==
name
)
return
persos
[
index
];
return
null
;
}
}
}
}
This diff is collapsed.
Click to expand it.
P03 Klassen/Perso.cs
+
1
−
1
View file @
555ebccb
...
@@ -19,7 +19,7 @@ namespace P03_Klassen
...
@@ -19,7 +19,7 @@ namespace P03_Klassen
naechstePersId
=
value
;
naechstePersId
=
value
;
}
}
}
}
readonly
string
Name
;
public
string
Name
{
get
;
private
set
;
}
public
int
Alter
public
int
Alter
{
{
get
=>
xyz01233
;
get
=>
xyz01233
;
...
...
This diff is collapsed.
Click to expand it.
P03 Klassen/Program.cs
+
6
−
1
View file @
555ebccb
...
@@ -13,7 +13,12 @@
...
@@ -13,7 +13,12 @@
anton
.
Ausgabe
();
anton
.
Ausgabe
();
//anton.NaechstePersId = 2000;
//anton.NaechstePersId = 2000;
Perso
berta
=
new
Perso
(
"Berta"
,
25
);
Perso
berta
=
new
Perso
(
"Berta"
,
25
);
Buergeramt
Nbg
=
new
Buergeramt
(
10
);
Nbg
.
NeuerPersonalausweis
(
"Meier"
,
15
);
Nbg
.
NeuerPersonalausweis
(
"Müller"
,
27
);
Console
.
WriteLine
(
Nbg
[
"Meier"
]);
Console
.
WriteLine
(
Nbg
[
1
]);
}
}
}
}
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment