当前位置: 首页>>代码示例>>C#>>正文


C# Class.Students方法代码示例

本文整理汇总了C#中Class.Students方法的典型用法代码示例。如果您正苦于以下问题:C# Class.Students方法的具体用法?C# Class.Students怎么用?C# Class.Students使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Class的用法示例。


在下文中一共展示了Class.Students方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Main

    static void Main(string[] args)
    {
        //We are given a school. In the school there are classes of students. Each class
        //has a set of teachers. Each teacher teaches a set of disciplines. Students have
        //name and unique class number. Classes have unique text identifier. Teachers have
        //name. Disciplines have name, number of lectures and number of exercises. Both teachers
        //and students are people. Students, classes, teachers and disciplines could have optional
        //comments (free text block).
        //Your task is to identify the classes (in terms of  OOP) and their attributes and operations,
        //encapsulate their fields, define the class hierarchy and create a class diagram with Visual Studio.

        //I use this class(class Scool) like a scool.
        try
        {
            //Initialize some students
            Student joro = new Student("Joro", 19877);
            Student petur = new Student("Petur", 19878);
            Student ivo = new Student("Ivo", 19879);

            //...some disciplines
            Discipline math = new Discipline("Mathematic", 8, 5);
            Discipline bio = new Discipline("Biology", 7, 3);

            // ... teacher
            Teacher ivanov = new Teacher("Ivanov");
            //Adding some disciplines that he teaching
            ivanov.SetOfDisciplines.Add(math);
            ivanov.SetOfDisciplines.Add(bio);

            //Make a class with students and teacher
            Class theBestClass = new Class("The best of the best");
            theBestClass.SetOfStudents.Add(joro);
            theBestClass.SetOfStudents.Add(petur);
            theBestClass.SetOfStudents.Add(ivo);
            theBestClass.SetOfTeachers.Add(ivanov);
            Console.WriteLine("Our clas - \"{0}\" have {1} studets :\n{2}and {3} teacher(s) :\n{4}"
                , theBestClass.UniqueTextIdentifier, theBestClass.SetOfStudents.Count, theBestClass.Students()
                , theBestClass.SetOfTeachers.Count, theBestClass.Teachers());

            //Add and show some optional comments
            ivo.AddComment("Ivo is football player");
            ivanov.AddComment("Mr. Ivanov do not like football players.");
            Console.WriteLine(ivo.ShowComment()+","+ivanov.ShowComment());

        }
        catch (Exception ex)
        {

            Console.WriteLine("Error!" + ex.Message); ;
        }
    }
开发者ID:Jarolim,项目名称:TelerikAcademy-1,代码行数:51,代码来源:School(main).cs


注:本文中的Class.Students方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。