Skip to content
Snippets Groups Projects
Select Git revision
  • 473357a25164f56514da648c61de7fbac2e9649a
  • master default protected
2 results

Personalausweis.cs

Blame
  • Personalausweis.cs 788 B
    using System;
    using System.Collections.Generic;
    using System.Text;
    
    namespace _01_3_Personalausweis
    {
        public class Personalausweis
        {
            public string Name { get; private set; }
            int id = 1000;
    
            static int naechste_ID = 1000;
    
            public Personalausweis(string Name)
            {
                this.Name = Name;
                id = NaechsteID++;
            }
    
            public static int NaechsteID
            {
                get => naechste_ID;
                set
                {
                    if (value < naechste_ID)
                        throw new ArgumentOutOfRangeException("Neue ID darf nicht kleiner dem aktuellen Stand sein");
                    naechste_ID = value;
                }
            }
            public override string ToString() => $"Name: {Name}, ID: {id}";
        }
    }