Skip to content
Snippets Groups Projects
Commit f0b9d198 authored by Uwe Wienkop's avatar Uwe Wienkop
Browse files

Klassen Handy & Personalausweis

parent a9d5c1b1
Branches
No related tags found
No related merge requests found
Showing
with 276 additions and 0 deletions
File added
No preview for this file type
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp3.1</TargetFramework>
<RootNamespace>_01Handy</RootNamespace>
</PropertyGroup>
</Project>
using System;
namespace _01Handy
{
class Handy
{
private string name;
private int id;
private static int naechsteId = 1000;
private static int handyCount = 0;
public static int HandyCount { get => handyCount; }
//public Handy(string name, int Id)
//{
// this.name = name;
// id = Id;
//}
public Handy(string name)
{
handyCount++;
this.name = name;
id = naechsteId;
naechsteId++;
}
//public int getId()
//{
// return id;
//}
public int getId() => id;
public void setId(int Wert)
{
if (Wert > 0)
id = Wert;
else
throw new ArgumentOutOfRangeException("Id muss positiv sein!");
}
public static int Id
{
get => naechsteId;
set {
if (value >= naechsteId)
naechsteId = value;
else
throw new ArgumentOutOfRangeException("Id muss positiv sein!");
}
}
public int Id2 { get; private set; }
public void IdAusgeben()
{
Console.WriteLine(this.id);
}
public override string ToString()
=> $"Handy: Name: {name}, Id: {id}";
}
class HandyShop
{
private Handy[] handyFeld;
private static int anzHandies = 0;
public HandyShop(int AnzHandies)
{
handyFeld = new Handy[AnzHandies];
}
public void AddHandy(Handy h)
{
handyFeld[anzHandies++] = h;
}
}
class Program
{
static void Main(string[] args)
{
Console.WriteLine($"Anzahl Handies: {Handy.HandyCount}");
Handy.Id = 1000;
Handy h1 = new Handy("Anton");
Handy h2 = new Handy("Berta");
Handy h3 = h1;
#region Intro
h3.IdAusgeben();
int h2Id = h2.getId();
h2.setId(5000);
h2.setId(h2.getId() + 1);
Console.WriteLine(h2.getId());
h2.Id = 5000;
h2.Id++;
Console.WriteLine(h2);
// h2 --> h2.ToString() {string}
#endregion
HandyShop newHandy = new HandyShop(1000);
newHandy.AddHandy(new Handy("Claudia"));
}
}
}
{
"runtimeTarget": {
"name": ".NETCoreApp,Version=v3.1",
"signature": ""
},
"compilationOptions": {},
"targets": {
".NETCoreApp,Version=v3.1": {
"01Handy/1.0.0": {
"runtime": {
"01Handy.dll": {}
}
}
}
},
"libraries": {
"01Handy/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\\oop-ss2023-wienkop\\OOP2023\\01Handy\\01Handy.csproj": {}
},
"projects": {
"C:\\Users\\wienkop\\source\\repos\\oop-ss2023-wienkop\\OOP2023\\01Handy\\01Handy.csproj": {
"version": "1.0.0",
"restore": {
"projectUniqueName": "C:\\Users\\wienkop\\source\\repos\\oop-ss2023-wienkop\\OOP2023\\01Handy\\01Handy.csproj",
"projectName": "01Handy",
"projectPath": "C:\\Users\\wienkop\\source\\repos\\oop-ss2023-wienkop\\OOP2023\\01Handy\\01Handy.csproj",
"packagesPath": "C:\\Users\\wienkop\\.nuget\\packages\\",
"outputPath": "C:\\Users\\wienkop\\source\\repos\\oop-ss2023-wienkop\\OOP2023\\01Handy\\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": {
"targetAlias": "netcoreapp3.1",
"projectReferences": {}
}
},
"warningProperties": {
"warnAsError": [
"NU1605"
]
}
},
"frameworks": {
"netcoreapp3.1": {
"targetAlias": "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\\5.0.416\\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.11.2</NuGetToolVersion>
</PropertyGroup>
<ItemGroup Condition=" '$(ExcludeRestorePackageImports)' != 'true' ">
<SourceRoot Include="C:\Users\wienkop\.nuget\packages\" />
</ItemGroup>
<PropertyGroup>
<MSBuildAllProjects>$(MSBuildAllProjects);$(MSBuildThisFileFullPath)</MSBuildAllProjects>
</PropertyGroup>
</Project>
\ 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>
<MSBuildAllProjects>$(MSBuildAllProjects);$(MSBuildThisFileFullPath)</MSBuildAllProjects>
</PropertyGroup>
</Project>
\ No newline at end of file
// <autogenerated />
using System;
using System.Reflection;
[assembly: global::System.Runtime.Versioning.TargetFrameworkAttribute(".NETCoreApp,Version=v3.1", FrameworkDisplayName = "")]
//------------------------------------------------------------------------------
// <auto-generated>
// Dieser Code wurde von einem Tool generiert.
// Laufzeitversion:4.0.30319.42000
//
// Änderungen an dieser Datei können falsches Verhalten verursachen und gehen verloren, wenn
// der Code erneut generiert wird.
// </auto-generated>
//------------------------------------------------------------------------------
using System;
using System.Reflection;
[assembly: System.Reflection.AssemblyCompanyAttribute("01Handy")]
[assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")]
[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")]
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0")]
[assembly: System.Reflection.AssemblyProductAttribute("01Handy")]
[assembly: System.Reflection.AssemblyTitleAttribute("01Handy")]
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]
// Von der MSBuild WriteCodeFragment-Klasse generiert.
85f60f993a44cf09110abb1ea2f759926e986823
is_global = true
build_property.RootNamespace = _01Handy
build_property.ProjectDir = C:\Users\wienkop\source\repos\oop-ss2023-wienkop\OOP2023\01Handy\
File added
File added
cc980dc576ce52bf3aa7b8b7ae480e6165538d79
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment