Zoo

 avatar
user_1419384
csharp
12 days ago
1.1 kB
3
Indexable
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Tema {
    internal class Zoo: ICloneable
        {
        string denumire;
        string adresa;

        List<Animal> lista=new List<Animal>();

        public string Denumire {
            get { return this.denumire; }
            set { this.denumire = value;}
        }

        public string Adresa {
            get { return this.adresa; }
            set { this.adresa = value;}
        }

        public List<Animal> Lista {
            get { return this.lista; }
            set { this.lista = value;}
        }

        object ICloneable.Clone() {
            return (this.MemberwiseClone());
        }

        public Zoo Clone() {
            Zoo Nou= (Zoo)((ICloneable)this).Clone();

            List<Animal> copie= new List<Animal>();

            foreach(Animal a in lista) {
                copie.Add(a.Clone());
            }

            Nou.lista = copie;

            return Nou;
        }
    }
}
Editor is loading...
Leave a Comment