Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • schneider/prog2-ss2020-wienkop
  • Wienkop/prog2-ss2020-wienkop
2 results
Show changes
Commits on Source (64)
Showing
with 249 additions and 3 deletions
{
"ExpandedNodes": [
"",
"\\01Buergeramt",
"\\01Indexer",
"\\01OperatorOverloading"
"\\10 OverrideVsNew"
],
"SelectedNode": "\\10 OverrideVsNew",
"PreviewInSolutionExplorer": false
}
\ No newline at end of file
File added
No preview for this file type
No preview for this file type
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp3.1</TargetFramework>
<RootNamespace>_01Buergeramt_Di</RootNamespace>
</PropertyGroup>
</Project>
using System;
namespace _01Buergeramt_Di
{
// DoJo-Klassenaufgabe:
#region Personalausweis
// Programmieren Sie eine Klasse Personalausweis mit folgenden Eigenschaften
// string name
// int id
// - Konstruktor: Erhält den Namen und vergibt eine neue, eindeutige Id (beginnend mit 1000)
// - Property zum Setzen und Lesen der nächsten Id. Beim Setzen muss die Id größer sein als die bisherige Nummer!
// Dieses Property muss vor dem Anlegen der ersten Person aufrufbar sein!
// - Property: Zum Lesen des Namens (kann auch als Auto-Property realisiert werden)
// - Überladene ToString-Methode: Soll den Namen und die Id ausgeben
#endregion
#region Bürgeramt
// Programmieren Sie zusätzlich eine Klasse Bürgeramt mit folgenden Eigenschaften
// string ort
// - Konstruktor, dem der Ortsname und die Anzahl der zu speichernden Personalausweise übergeben werden
// - Methode NeuerAusweis: Erhält den Namen, legt einen neuen Pass an, speichert diesen im Feld an der
// nächsten freien Stelle und liefert den Personalausweis zurück
// - Optional: Methode AllePersos(string teilname): liefert ein Feld passender Größe mit allen
// Personalausweisen zurück, die den "teilnamen" enthalten (Tipp: String-Methode contains)
// Main: Legen Sie zwei Bürgerämter an (Nürnberg/Fürth) und lassen Sie für Nürnberg mehrere Pässe erzeugen
// Optional: Rufen Sie AllePersos mit einem passenden Teilnamen auf und geben Sie diese aus!
#endregion
class Personalausweis
{
public string name { get; private set; }
int id;
static int naechsteID = 1000;
public Personalausweis(string name)
{
this.name = name;
this.id = naechsteID++;
}
public static int NaechsteID
{
get => naechsteID;
set
{
if (value >= naechsteID)
naechsteID = value;
else
throw new ArgumentOutOfRangeException("Naechste ID muss größer sein!");
}
}
public override string ToString() => $"Name: {name} Id: {id}";
}
class Buergeramt
{
string ort;
Personalausweis[] personalausweise;
int ausweisIndex = 0;
public Buergeramt(string ort, int anzahlAusweise)
{
this.ort = ort;
personalausweise = new Personalausweis[anzahlAusweise];
}
public Personalausweis NeuerAusweis(string name)
{
if (ausweisIndex >= personalausweise.Length)
throw new IndexOutOfRangeException("Zuviele Ausweise");
personalausweise[ausweisIndex] = new Personalausweis(name);
return personalausweise[ausweisIndex++];
}
}
class Program
{
static void Main(string[] args)
{
Personalausweis.NaechsteID = 2000;
Console.WriteLine(Personalausweis.NaechsteID);
Personalausweis p1 = new Personalausweis("Anton");
Personalausweis.NaechsteID = 3000;
Console.WriteLine(p1);
Buergeramt BuergeramtNuernberg = new Buergeramt("Nürnberg", 600000);
Personalausweis mueller = BuergeramtNuernberg.NeuerAusweis("Müller");
}
}
}
{
"runtimeTarget": {
"name": ".NETCoreApp,Version=v3.1",
"signature": ""
},
"compilationOptions": {},
"targets": {
".NETCoreApp,Version=v3.1": {
"01Buergeramt-Di/1.0.0": {
"runtime": {
"01Buergeramt-Di.dll": {}
}
}
}
},
"libraries": {
"01Buergeramt-Di/1.0.0": {
"type": "project",
"serviceable": false,
"sha512": ""
}
}
}
\ No newline at end of file
File added
File added
File added
{
"runtimeOptions": {
"additionalProbingPaths": [
"C:\\Users\\wienkop\\.dotnet\\store\\|arch|\\|tfm|",
"C:\\Users\\wienkop\\.nuget\\packages"
]
}
}
\ No newline at end of file
{
"runtimeOptions": {
"tfm": "netcoreapp3.1",
"framework": {
"name": "Microsoft.NETCore.App",
"version": "3.1.0"
}
}
}
\ No newline at end of file
{
"runtimeTarget": {
"name": ".NETCoreApp,Version=v3.1",
"signature": ""
},
"compilationOptions": {},
"targets": {
".NETCoreApp,Version=v3.1": {
"01Uebg_Buergeramt-Di/1.0.0": {
"runtime": {
"01Uebg_Buergeramt-Di.dll": {}
}
}
}
},
"libraries": {
"01Uebg_Buergeramt-Di/1.0.0": {
"type": "project",
"serviceable": false,
"sha512": ""
}
}
}
\ No newline at end of file
File added
File added
File added
{
"runtimeOptions": {
"additionalProbingPaths": [
"C:\\Users\\wienkop\\.dotnet\\store\\|arch|\\|tfm|",
"C:\\Users\\wienkop\\.nuget\\packages"
]
}
}
\ No newline at end of file
{
"runtimeOptions": {
"tfm": "netcoreapp3.1",
"framework": {
"name": "Microsoft.NETCore.App",
"version": "3.1.0"
}
}
}
\ No newline at end of file
{
"format": 1,
"restore": {
"C:\\Users\\wienkop\\source\\repos\\01Buergeramt-Di\\01Buergeramt-Di.csproj": {}
},
"projects": {
"C:\\Users\\wienkop\\source\\repos\\01Buergeramt-Di\\01Buergeramt-Di.csproj": {
"version": "1.0.0",
"restore": {
"projectUniqueName": "C:\\Users\\wienkop\\source\\repos\\01Buergeramt-Di\\01Buergeramt-Di.csproj",
"projectName": "01Buergeramt-Di",
"projectPath": "C:\\Users\\wienkop\\source\\repos\\01Buergeramt-Di\\01Buergeramt-Di.csproj",
"packagesPath": "C:\\Users\\wienkop\\.nuget\\packages\\",
"outputPath": "C:\\Users\\wienkop\\source\\repos\\01Buergeramt-Di\\obj\\",
"projectStyle": "PackageReference",
"configFilePaths": [
"C:\\Users\\wienkop\\AppData\\Roaming\\NuGet\\NuGet.Config",
"C:\\Program Files (x86)\\NuGet\\Config\\Microsoft.VisualStudio.Offline.config"
],
"originalTargetFrameworks": [
"netcoreapp3.1"
],
"sources": {
"C:\\Program Files (x86)\\Microsoft SDKs\\NuGetPackages\\": {},
"https://api.nuget.org/v3/index.json": {}
},
"frameworks": {
"netcoreapp3.1": {
"projectReferences": {}
}
},
"warningProperties": {
"warnAsError": [
"NU1605"
]
}
},
"frameworks": {
"netcoreapp3.1": {
"imports": [
"net461",
"net462",
"net47",
"net471",
"net472",
"net48"
],
"assetTargetFallback": true,
"warn": true,
"frameworkReferences": {
"Microsoft.NETCore.App": {
"privateAssets": "all"
}
},
"runtimeIdentifierGraphPath": "C:\\Program Files\\dotnet\\sdk\\3.1.201\\RuntimeIdentifierGraph.json"
}
}
}
}
}
\ No newline at end of file
<?xml version="1.0" encoding="utf-8" standalone="no"?>
<Project ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup Condition=" '$(ExcludeRestorePackageImports)' != 'true' ">
<RestoreSuccess Condition=" '$(RestoreSuccess)' == '' ">True</RestoreSuccess>
<RestoreTool Condition=" '$(RestoreTool)' == '' ">NuGet</RestoreTool>
<ProjectAssetsFile Condition=" '$(ProjectAssetsFile)' == '' ">$(MSBuildThisFileDirectory)project.assets.json</ProjectAssetsFile>
<NuGetPackageRoot Condition=" '$(NuGetPackageRoot)' == '' ">$(UserProfile)\.nuget\packages\</NuGetPackageRoot>
<NuGetPackageFolders Condition=" '$(NuGetPackageFolders)' == '' ">C:\Users\wienkop\.nuget\packages\</NuGetPackageFolders>
<NuGetProjectStyle Condition=" '$(NuGetProjectStyle)' == '' ">PackageReference</NuGetProjectStyle>
<NuGetToolVersion Condition=" '$(NuGetToolVersion)' == '' ">5.5.0</NuGetToolVersion>
</PropertyGroup>
<PropertyGroup>
<MSBuildAllProjects>$(MSBuildAllProjects);$(MSBuildThisFileFullPath)</MSBuildAllProjects>
</PropertyGroup>
</Project>
\ No newline at end of file