티스토리 뷰

IT Skills/Programming

C#-수강신청

E-yarn 2013. 4. 10. 20:20

using System;

using System.Collections.Generic;

using System.Linq;

using System.Text;


namespace ConsoleApplication4

{

    public class Student

    {

        private string name;

        private string hakbun;

        private string phone_num;

        private string grade;


        public Student(string Hakbun, string Name, string Phone_num)

        {

            this.hakbun = Hakbun;

            this.name = Name;

            this.phone_num = Phone_num;

        

        }

        public string G_Hakbun

        {   

            get { return this.hakbun; } 

        }

        public string GS_Name

        { 

            get { return this.name; }

            set { this.name = value; }

        }

        public string GS_Phone_num

        { 

            get { return this.phone_num; } 

            set { this.phone_num = value;  }

        }

        public string GS_grade

        {

            get { return this.grade; }

            set { this.grade = value; }

        }

    }

    public class Teacher

    {

        private string name;

        private string sabun;

        private string phone_num;


        public Teacher(string Sabun, string Name, string Phone_num)

        {

            this.sabun = Sabun;

            this.name = Name;

            this.phone_num = Phone_num;

        }


        public string G_Name

        {

            get { return this.name;}

            set { this.name = value; }

        }

        public string G_Sabun

        {

            get { return this.sabun; }

        }


        public string Phone_num

        {

            get { return this.phone_num; }

            set { this.phone_num = value; }

        }

    }

    public class Subject

    {

        private string num;

        private string sub_name;

        private string sub_what;

        public string G_Num

        {

            get { return this.num; }

        }

        public string G_Sub_name

        {

            get { return this.sub_name; }

        }


        public string G_Sub_what

        {

            get { return this.sub_what; }

            set { this.sub_what = value; }

        }

        public Subject(string Num, string Sub_name, string Sub_what)

        {

            this.num = Num;

            this.sub_name = Sub_name;

            this.sub_what = Sub_what;

        }  

    }


    public class Course

    {

        private Subject subject;

        private Teacher teacher;

        private Student[] students;

        private int studentCurrentNumber;

        private int studentMaxNumber;


        public Course(int no, Subject sub, Teacher tc)

        {

            this.studentMaxNumber = no;

            this.students = new Student[this.studentMaxNumber];

            this.studentCurrentNumber = 0;

            this.subject = sub;

            this.teacher = tc;

        }


        public Teacher GetTeacher()

        {

            return this.teacher;

        }

        public Student[] GetStudents()

        {

            return this.students;

        }

        public Subject GetSubject()

        {

            return this.subject;

        }


        public void AddStudent(Student std)

        {

            if (this.studentCurrentNumber < this.studentMaxNumber)

            {

                students[this.studentCurrentNumber++] = std;

                Console.WriteLine("현재 학생 수는 " + this.studentCurrentNumber + "입니다.");

            }

            else

            {

                Console.WriteLine("[정원초과] 현재 학생수 : " + this.studentCurrentNumber);

            }

        }

    }



    class MainApp

    {

        static void Main(string[] args)

        {

            

            Teacher tc = new Teacher("091111", "김강사씨", "010-0000-1111");

            Subject sj = new Subject("CS0823", "C#프로그래밍", "C#을 통해서 객체지향을 이해하자");


            Course cs = new Course(3, sj, tc);


            Student std;

            std = new Student("120012", "김학생씨", "010-1111-1111");

            cs.AddStudent(std); 

            std = new Student("120013", "이학생씨", "010-1111-1111");

            cs.AddStudent(std);

            std = new Student("120014", "박학생씨", "010-1111-1111");

            cs.AddStudent(std);

            std = new Student("120015", "최학생씨", "010-1111-1111");

            cs.AddStudent(std);


            foreach (Student s in cs.GetStudents())

            {

                Console.WriteLine(s.GS_Name);

            }

            

        }

        

    }

}

댓글
공지사항
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday
링크
«   2025/04   »
1 2 3 4 5
6 7 8 9 10 11 12
13 14 15 16 17 18 19
20 21 22 23 24 25 26
27 28 29 30
글 보관함