GetClone() 공개 메소드

public GetClone ( IAnimal animalSample ) : IAnimal
animalSample IAnimal
리턴 IAnimal
        void OnEnable()
        {
            Debug.Log ("------------------");
            Debug.Log ("PROTOTYPE DESIGN PATTERN");
            CloneFactory factory = new CloneFactory();

            Sheep sally = new Sheep();

            Sheep clonedSheep = (Sheep) factory.GetClone(sally);

            Debug.Log ("Sally: " + sally.ToString());
            Debug.Log ("Clone of Sally: " + clonedSheep.ToString());
            Debug.Log ("Sally Hash: " + sally.GetHashCode() + " - Cloned Sheep Hash: " + clonedSheep.GetHashCode());
        }
        void OnEnable()
        {
            Debug.Log("------------------");
            Debug.Log("PROTOTYPE DESIGN PATTERN");
            CloneFactory factory = new CloneFactory();

            Sheep sally = new Sheep();

            Sheep clonedSheep = (Sheep)factory.GetClone(sally);

            Debug.Log("Sally: " + sally.ToString());
            Debug.Log("Clone of Sally: " + clonedSheep.ToString());
            Debug.Log("Sally Hash: " + sally.GetHashCode() + " - Cloned Sheep Hash: " + clonedSheep.GetHashCode());
        }
예제 #3
0
        static void Main(string[] args)
        {
            CloneFactory animalMaker = new CloneFactory();

            Sheep sally = new Sheep();

            Sheep clonedSheep = (Sheep)animalMaker.GetClone(sally);

            Console.WriteLine(sally);

            Console.WriteLine(clonedSheep);

            Console.WriteLine($"Sally Hashcode {sally.GetHashCode()}");

            Console.WriteLine($"Cloned Hashcode {clonedSheep.GetHashCode()}");

            Console.ReadKey();
        }