Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Kolcsonzo
- {
- int? id; //Identity
- string megnevezes;
- string cim;
- List<Jarmu> jarmuvek;
- public int? Id
- {
- get => id;
- set
- {
- //if (id == null)
- if (id == default)
- {
- id = value;
- }
- else
- {
- throw new InvalidOperationException("Az ID értéke csak egyszer változhat és nem módosítható!");
- }
- }
- }
- public string Megnevezes
- {
- get => megnevezes;
- set
- {
- if (value.Length >= 3)
- {
- megnevezes = value;
- }
- else
- {
- throw new ArgumentException("A kölcsönző megnevezése minimum 3 karakteres kell legyen!");
- }
- }
- }
- public string Cim { get => cim; /*set => cim = value;*/ }
- internal List<Jarmu> Jarmuvek { get => jarmuvek; /*set => jarmuvek = value;*/ }
- //Az adatbázisból való felolvasáshoz
- public Kolcsonzo(int? id, string megnevezes, string cim) : this(megnevezes, cim)
- {
- Id = id;
- }
- //A programban való létrehozáshoz
- public Kolcsonzo(string megnevezes, string cim)
- {
- Megnevezes = megnevezes;
- this.cim = cim;
- }
- public override string ToString()
- {
- //return base.ToString();
- return megnevezes;
- }
- public override bool Equals(object obj)
- {
- //return base.Equals(obj);
- return obj is Kolcsonzo masik && masik.id == this.id;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement