ABOUT ME

-

Today
-
Yesterday
-
Total
-
  • 객체지향 소스
    Writer/WarmingUp Code 2008. 10. 7. 14:02
    반응형
    using System;

    namespace nam{
        class Student{
            public string Name;
            public int Age;
            public int cNum;

            public void setStudent(){
                Console.Write("이름을 입력해라.");
                this.Name = Console.ReadLine();
                Console.WriteLine("나이를 입력해라.");
                this.Age = int.Parse(Console.ReadLine());
                Console.WriteLine("학번을 입력해라.");
                this.cNum = int.Parse(Console.ReadLine());
            }
            public void getStudent(){
                Console.WriteLine("{0}, {1}, {2} ",this.Name,this.Age,this.cNum);
            }
        }// end class Student
        class studentTest
        {
            public static void ShowMenu()
            {
                Console.WriteLine("***************************************************");
                Console.WriteLine(" 1:입력\t2:list보기\t3:\t4:종료");
                Console.WriteLine("***************************************************");
            }
            static void Main()
            {
                int count = 0;
                Student[] testStudent = new Student[10];
                bool test = true;
                while (test)
                {
                    ShowMenu();
                    int uChoice = Convert.ToInt32(Console.ReadLine());
                    switch (uChoice)
                    {
                        case 1:
                            {
                                Student tmpStu = new Student();
                                tmpStu.setStudent();
                                //Student testStudent = new Student();
                                testStudent[count++] = tmpStu;
                            }
                            break;
                        case 2:
                            {
                                for (int i = 0; i < count; i++)
                                {
                                    testStudent[i].getStudent();
                                }
                            }
                            break;
                        case 3:
                            break;
    }
     }
        }
     }
             }
    반응형

    댓글

Designed by Tistory.