Пример #1
0
        /*
         * static void Introduce(Marine m)
         * {
         *  Console.Write("i am");
         *  Console.WriteLine(m.SayName());
         *  Console.WriteLine("thank you");
         *
         * }
         * static void Introduce(Firebat f)
         * {
         *  Console.Write("i am");
         *  Console.WriteLine(f.SayName());
         *  Console.WriteLine("thank you");
         *
         * }
         */// 제네릭을 사용하지 않을 경우 다음과 같은 Introduce를 통해 marine과 firebat를 만들어야 한다.

        static void Main(string[] args)
        {
            Marine m = new Marine(3, "a");

            Introduce(m);


            IntStack stack = new IntStack();

            stack.Push(3);
            stack.Push(5);
            stack.Push(1);
            stack.Push(2);

            Console.WriteLine(stack.Pop());
            Console.WriteLine(stack.Pop());
            Console.WriteLine(stack.Pop());
            Console.WriteLine(stack.Pop());

            MarineStack ms = new MarineStack();

            ms.Push(new Marine(3, "a"));
            ms.Push(new Marine(5, "b"));
            ms.Push(new Marine(1, "c"));
            ms.Push(new Marine(2, "d"));

            Console.WriteLine(ms.Pop());
        }
Пример #2
0
        static void Main(string[] args)
        {
            Marine m = new Marine(3, "john");

            Introduce(m);

            Firebat f = new Firebat();

            Introduce(f);
            return;



            var stack = new Stack <int>(); // var 동적타입X

            stack.Push(3);
            stack.Push(5);
            stack.Push(1);
            stack.Push(2);

            Console.WriteLine(stack.Pop());
            Console.WriteLine(stack.Pop());
            Console.WriteLine(stack.Pop());
            Console.WriteLine(stack.Pop());

            var ms = new Stack <Marine>();

            ms.Push(new Marine(3, "john"));
            ms.Push(new Marine(5, "paul"));
            ms.Push(new Marine(1, "george"));
            ms.Push(new Marine(2, "ringo"));

            Console.WriteLine(ms.Pop());
            Console.WriteLine(ms.Pop());
            Console.WriteLine(ms.Pop());
            Console.WriteLine(ms.Pop());
        }
Пример #3
0
 static void Introduce(Marine m)
 {
     Console.Write("I am ");
     Console.WriteLine(m.SayName());
     Console.WriteLine("Thank you");
 }
Пример #4
0
 public void Push(Marine x)
 {
     _list.Add(x);
     _index++;
 }