コード例 #1
0
        static void uniApp()
        {
            Student student1 = new Student(name: "student1", age: 1);
            Student student2 = new Student(name: "student2", age: 2);
            Student student3 = new Student(name: "student3", age: 3);

            Console.WriteLine($"Total students: {Student.totalStudents()}");
            Teacher teacher1 = new Teacher("teacher1", 1);
            // ArrayList studArr = new ArrayList();
            List <Student> studArr = new List <Student>();

            studArr.Add(student1);
            studArr.Add(student2);
            studArr.Add(student3);
            List <Teacher> teachArr = new List <Teacher>();

            teachArr.Add(teacher1);
            Course        course1   = new Course(name: "Programming with C#", students: studArr, teachers: teachArr);
            List <Course> courseArr = new List <Course>();

            courseArr.Add(course1);
            Degree        degree1   = new Degree(name: "Bachelor's", courses: courseArr);
            List <Degree> degreeArr = new List <Degree>();

            degreeArr.Add(degree1);
            UProgram uprog = new UProgram(name: "Information Technology", degrees: degreeArr);

            // Console statements;
            Console.WriteLine($"Name of the program: {uprog.Name}");
            Console.WriteLine($"Name of Degree in program is: {uprog.Degree[0].Name}");
            Console.WriteLine($"Name of course in degree is: {uprog.Degree[0].Courses[0].CourseName}");
            Console.WriteLine($"Number of students in this course is: {uprog.Degree[0].Courses[0].students.Count}");
        }
コード例 #2
0
        static void Main(string[] args)
        {
            Student student1 = new Student();
            Student student2 = new Student();
            Student student3 = new Student();

            Course programming = new Course();

            programming.add_Students(student1, student2, student3);
            programming.name = "Programming with C#";
            int num_students = programming.count_students();

            Teacher teacher1 = new Teacher();

            programming.add_Teacher(teacher1);

            Degree Bachelor = new Degree();

            Bachelor.degree_name = "Bachelor of Science";
            Bachelor.course      = programming;

            UProgram Program1 = new UProgram();

            Program1.name   = "Information Technology";
            Program1.degree = Bachelor;

            Console.WriteLine("The {0} program contains the {1} degree.", Program1.name, Bachelor.degree_name);
            Console.WriteLine("The {0} degree contains the course {1}", Bachelor.degree_name, programming.name);
            Console.WriteLine("The {0} course contains {1} student(s).", programming.name, num_students);

            Console.WriteLine("");
            Console.WriteLine("Press any key to exit.");
            Console.ReadKey();
        }
コード例 #3
0
            public static UProgram makeInstanceFromConsoleInput()
            {
                UProgram program = new UProgram();

                program.fillFromConsoleInput();
                return(program);
            }
コード例 #4
0
 //overload for UProgram
 static void PrintDetails(UProgram prog)
 {
     Console.WriteLine("UProgram Details");
     Console.WriteLine("Program's Name : {0}", prog.programName);
     Console.WriteLine("Department Head: {0} ", prog.departmentHead);
     Console.WriteLine("Related degrees: {0} ", prog.degrees);
     Console.WriteLine("=========");
 }
コード例 #5
0
 //overload for UProgram
 static void GetInformation(out UProgram prog)
 {
     Console.WriteLine("Enter the Prorgam's Name: ");
     prog.programName = Console.ReadLine();
     Console.WriteLine("Enter the department Head's name");
     prog.departmentHead = Console.ReadLine();
     Console.WriteLine("Enter the degrees related to the Program");
     prog.degrees = Console.ReadLine();
 }
コード例 #6
0
        static void Main(string[] args)
        {
            //INSTATIATE EACH OBJECT: student, teacher, Uprogram

            // Instantiate a UProgram object called Business.
            UProgram newProgram = new UProgram("Information Technology");

            // Instantiate a Degree object, such as Bachelor, inside the UProgram object.
            Degree newDegree = new Degree("Bachelor");
            newProgram.degrees[0] = newDegree; / /Bachelor degree in 'IT program' located at index 0
コード例 #7
0
        //Add static before copying into forum
        public void Main(string[] args)
        {
            /*Leaving some fields with empty values to ease of assignment*/
            Student student1 = new Student("Carlo", "Poppa", DateTime.Now, string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, string.Empty);

            student1.AddGrade("A");
            student1.AddGrade("B");
            student1.AddGrade("C");
            student1.AddGrade("D");
            student1.AddGrade("F");

            Student student2 = new Student("Super", "Commuter", DateTime.Now, string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, string.Empty);

            student2.AddGrade("A");
            student2.AddGrade("A");
            student2.AddGrade("A");
            student2.AddGrade("B");
            student2.AddGrade("A");

            Student student3 = new Student("Kellee", "Maze", DateTime.Now, string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, string.Empty);

            student2.AddGrade("C");
            student2.AddGrade("A");
            student2.AddGrade("A");
            student2.AddGrade("B");
            student2.AddGrade("A");


            /*Using some empty values for simplicity shake*/
            Teacher teacher = new Teacher("Dr.", "Madu", "Rao", DateTime.Now, string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, "Information Technology");


            /*Using some empty values for simplicity shake*/
            //List<T> created inline of Course constructor
            //Using object initalizer rather than .Add() methods
            //Documentation: https://msdn.microsoft.com/en-us/library/bb384062.aspx
            var course = new Course("Dev204x", "Programming with C#", "Programming", 5, teacher, new List <Student> {
                student1, student2, student3
            });
            var degree = new Degree("Bachelor", "Computer Science", 400, course);

            //List<T> created inline of Program constructor
            //Using object initalizer rather than .Add() methods
            //Documentation: https://msdn.microsoft.com/en-us/library/bb384062.aspx
            var program = new UProgram("Information Technology", new List <string> {
                "Bachelor", "Masters"
            }, teacher, degree);

            program.Degree.Course.ListStudents();

            Console.WriteLine("Press any key to continue...");
            Console.ReadKey();
        }
コード例 #8
0
        static void Main(string[] args)
        {
            // Creating three student objects, since it's at least three.

            Student stud1 = new Student("Surya", "Raman", "*****@*****.**");
            Student stud2 = new Student("Narendra", "Mdoi","*****@*****.**");
            Student stud3 = new Student("Barack", "Obama", "*****@*****.**");

            //Now creating the course object with dev204X

            Course course = new Course("DEV204X", 5);

            //Using the method at the end of this code to add students to course

            course.addStudent(stud1);
            course.addStudent(stud2);
            course.addStudent(stud3);

            // Creating one teacher object since that's the minimum number

            Teacher teacher = new Teacher("Bruce", "Wayne", "*****@*****.**");

            // Using the method at the end of this code to add teacher to course

            course.addTeacher(teacher);

            // Creating Degree object, assuming Computer Science and Engineering degree

            Degree degree = new Degree("Computer Science and Engineering", 250, null);

            // Adding Course object to the Degree object

            degree.Course = course;

            //Creating UProgram object with Bachelor of Engineering

            UProgram uProgram = new UProgram("Bachelor of Engineering", "Lex Luthor", null);

            // Adding the Degree object to the UProgram object

            uProgram.Degree = degree;

            // Printing everything as per the Assignment instructions

            Console.WriteLine("The {0} program contains the {1} degree\n", uProgram.ProgramName, degree.DegreeName);

            Console.WriteLine("The {0} degree contains the course {1}\n", degree.DegreeName, course.CourseName);
            
            Console.WriteLine("The {0} course contains {1} student(s)\n", course.CourseName, course.studentNumber);
            Console.ReadKey();
        }
コード例 #9
0
ファイル: module7.cs プロジェクト: sojeri/ada
    public static void Main()
    {
        // - Instantiate at least one Teacher object.
        Teacher[] teachers = GenerateThreeTeachers();

        // - Instantiate a Course object called Programming with C#.
        // - Add that Teacher object to your Course object
        Course[] courses = { new Course("Programming with C#", 15, 10, teachers) };

        // - Instantiate three Student objects.
        // - Add your three students to this Course object.
        GenerateThreeStudents(ref courses[0]);

        // - Instantiate a Degree object, such as Bachelor.
        // - Add your Course object to the Degree object.
        Degree[] degrees = { new Degree("Bachelor of Skience", 180, courses) };

        // - Instantiate a UProgram object called Information Technology.
        // - Add the Degree object to the UProgram object.
        UProgram program = new UProgram(
            "Information Technology",
            "The King of Pokemanz",
            degrees
            );

        // - Using Console.WriteLine statements, output the following information to
        //   the console window:
        //   - The name of the program and the degree it contains.
        Console.WriteLine(
            "The {0} program contains the {1} degree.",
            program.Name,
            program.Degrees[0].Name
            );
        //   - The name of the course in the degree.
        Console.WriteLine(
            "The {0} degree contains the course {1}.",
            degrees[0].Name,
            degrees[0].Courses[0].Name
            );
        //   - The count of the number of students in the course.
        Console.WriteLine(
            "The {0} course contains {1} student(s).",
            courses[0].Name,
            Student.TotalEnrolled
            );

        //   - The students' first and last names.
        courses[0].ListStudents();
    }
コード例 #10
0
ファイル: Program.cs プロジェクト: BigPopeye/Learning
        static void Main(string[] args)
        {
            UProgram Program1 = new UProgram("Information Technology");

            Student Student1 = new Student("Amy", "Female", 20);
            Student Student2 = new Student("Bob", "Male", 21);
            Student Student3 = new Student("Candy", "Female", 21);

            Course Course1 = new Course("Programming with C#");
            Course Course2 = new Course("SQL");

            Student1.TakeCourse(Course1);
            Student2.TakeCourse(Course1);
            Student3.TakeCourse(Course2);

            Teacher Teacher1 = new Teacher("Alex", "Male");

            Course1.AddTeacher(Teacher1);

            Teacher Teacher2 = new Teacher("Phonex", "Female");

            Degree Degree1 = new Degree("Bachelor");

            Degree1.AddCourse(Course1);
            Degree1.AddCourse(Course2);

            Program1.AddDegree(Degree1);

            Console.WriteLine($"Program Name : {Program1.Name} , more information :");
            foreach (var degree in Program1.Degrees)
            {
                if (degree == null)
                {
                    break;
                }
                Console.WriteLine($"Degree : {degree.Name} . Courses contains:");
                foreach (var course in degree.Courses)
                {
                    if (course == null)
                    {
                        break;
                    }
                    Console.WriteLine($"\n\tCourse  : {course.Name}");
                    Console.WriteLine($"\tProfessor : {course.CourseTeacher}");
                    Console.WriteLine($"\t\tStudents enrolled: {course.NumberEnroll}");
                }
            }
            Console.WriteLine($"Thank you!");
        }
コード例 #11
0
ファイル: edX4.cs プロジェクト: kbuzby/edX
    public static UProgram forProgram()
    {
        UProgram prog1 = new UProgram();

        WriteLine("Enter the name of the new program: ");
        prog1.name = ReadLine();
        WriteLine("Enter the degrees in this program: ");
        prog1.degrees = ReadLine();
        WriteLine("Enter the faculty in this program: ");
        prog1.faculty = ReadLine();
        WriteLine("Enter the head of this program: ");
        prog1.head = ReadLine();

        return(prog1);
    }
        public void Main(string[] args)
        {
            /*Leaving some fields with empty values to ease of assignment*/
            Student student1 = new Student("Carlo", "Poppa", DateTime.Now, string.Empty, string.Empty, string.Empty,
                                           string.Empty, string.Empty, string.Empty, string.Empty);
            Student student2 = new Student("Super", "Commuter", DateTime.Now, string.Empty, string.Empty, string.Empty,
                                           string.Empty, string.Empty, string.Empty, string.Empty);
            Student student3 = new Student("Kellee", "Maze", DateTime.Now, string.Empty, string.Empty, string.Empty,
                                           string.Empty, string.Empty, string.Empty, string.Empty);

            /*Using some empty values for simplicity shake*/
            Teacher teacher = new Teacher("Dr.", "Madu", "Rao", DateTime.Now, string.Empty, string.Empty, string.Empty,
                                          string.Empty, string.Empty, string.Empty, "Information Technology");

            Course course = new Course("Dev204x", "Programming with C#", "Programming", 5, teacher,
                                       new[] { student1, student2, student3 });
            Degree   degree  = new Degree("Bachelor", "Computer Science", 400, course);
            UProgram program = new UProgram("Information Technology", new[] { "Bachelor", "Masters" }, teacher, degree);

            var sb = new StringBuilder();

            sb.AppendFormat("The {0} program contains the {1} of {2} degree", program.Name, program.Degree.Level,
                            program.Degree.Major).AppendLine();
            sb.AppendLine();
            sb.AppendFormat("The {0} of {1} degree contains the course {2}", program.Degree.Level, program.Degree.Major,
                            program.Degree.Course.Title).AppendLine();
            sb.AppendLine();
            sb.AppendFormat("Teacher: {0} {1} {2}", program.Degree.Course.Teacher.PreFix,
                            program.Degree.Course.Teacher.FirstName,
                            program.Degree.Course.Teacher.LastName).AppendLine();
            sb.AppendLine();
            sb.AppendFormat("The {0} course contains {1} student(s)", program.Degree.Course.Title,
                            Student.NumberOfStudents).AppendLine();
            sb.AppendLine();
            sb.AppendLine(program.Degree.Course.Teacher.GiveTest());
            sb.AppendLine();
            sb.AppendLine("\tStudents: ");
            foreach (var student in program.Degree.Course.Students)
            {
                sb.AppendFormat("\t   {0}, {1} - They took a test: {2}", student.FirstName, student.LastName,
                                student.TakeTest()).AppendLine();
            }

            Console.WriteLine(sb.ToString());
            Console.WriteLine("Press any key to continue...");
            Console.ReadLine();
        }
コード例 #13
0
ファイル: Program.cs プロジェクト: Trung1234/CsharpPractices
        static void Main(string[] args)
        {
            IList <Student> students = new List <Student>()
            {
                new Student("Libby", "English"),
                new Student("Alex", "English")
            };
            Teacher teacher1    = new Teacher("Bob", "English");
            Course  programming = new Course {
                Name     = "Programing",
                Students = students,
                Teachers = new List <Teacher> {
                    teacher1
                }
            };
            Degree bachelor = new Degree
            {
                Name    = "Bachelor",
                Courses = new List <Course> {
                    programming
                }
            };
            UProgram informationTechnology = new UProgram
            {
                Name    = "Information Technology",
                Degrees = new List <Degree> {
                    bachelor
                }
            };

            Console.WriteLine("The name of the program : {0}", informationTechnology.Name);
            Console.WriteLine("The name of the degree : {0}", bachelor.Name);
            Console.WriteLine("The name of the course in the degree : {0}", programming.Name);
            Console.WriteLine("Teacher's Information : {0}", teacher1.toString());
            teacher1.GradeTest();
            Console.WriteLine("Student's Information :");
            foreach (var student in students)
            {
                Console.WriteLine(student.toString());
                student.TakeTest();
            }

            Console.WriteLine("The number of students : {0}", students.Count);
            Console.ReadLine();
        }
コード例 #14
0
ファイル: Program.cs プロジェクト: sophie-greene/Csharp
 static void Main(string[] args)
 {
     string[] atts = { "Sophie", "Greene", "1/12/1991", "30 Some Street", "", "Leeds", "West Yorkshire", "ZE7 3AE", "UK","Student" };
     string[] att = { "Manual", "Zu", "1/12/1937", "30 Other Street", "", "Sheffield", "West Yorkshire", "LE7 9MN", "UK","Teacher" };
     Person student = new Person(atts);
     student.print();
     Person teacher = new Person(att);
     teacher.print();
     //ensure console window stays open
     string[] pAtt = {"Intro to Computer Science","Some Guy","BSc. blah blah" };
     UProgram prog = new UProgram(pAtt);
     prog.print();
     Degree deg = new Degree("Bsc. A M", 72);
     deg.print();
     Course cour = new Course("Intro hbla", 3, 9, "Mr blah Person");
     cour.print();
     Console.Read();
 }
コード例 #15
0
ファイル: Program.cs プロジェクト: n873/Microsoft-DEV204.2x
        static void Main(string[] args)
        {
            var uProgram = new UProgram("Information Technology")
            {
                Degree = new Degree("Bachelor")
                {
                    Course = new Course("Programming with C#")
                }
            };

            uProgram.Degree.Course.AddStudent(new Student());
            uProgram.Degree.Course.AddStudent(new Student());
            uProgram.Degree.Course.AddStudent(new Student());

            Student myStudent = new Student();
            Person  myPerson  = myStudent;

            System.Console.WriteLine($"{uProgram.Title}, {uProgram.Degree.Title}, {uProgram.Degree.Course.Title}, {uProgram.Degree.Course.Students.Count}");
        }
コード例 #16
0
        static void Main(string[] args)
        {
            UProgram infoTech = new UProgram();
            //infoTech object must have Name string "Information Technology", length int Months = 60, degree string "Bachelor"
            Student student1 = new Student();
            //Student1 and similar objects must have Name and Surname String, DOB DateTime, Address and loads other details if required
            //Student has a mandatory counter, I'll call it "enrolled_people"
            //Interesting to instantiate students with missing data
            Course progrC = new Course();
            //ProgrC object must have at least a Name string "Programming with C#"
            Teacher teacher1 = new Teacher();
            //teacher1 has a name and surname string
            Degree degree = new Degree();

            //degree must have the value Name string "Bachelor"

            Console.WriteLine($"The programme is called {infoTech.Name}");
            Console.WriteLine($"{infoTech.Name} contains a {degree.Name} degree");
            Console.WriteLine($"This degree contains a few courses and one of them is {progrC.Name}");
            Console.WriteLine($"By now there are only {Student.enrolled_people} enrolled in {progrC.Name}");
        }
コード例 #17
0
        static void Main(string[] args)
        {
            var uProgram = new UProgram("Информационные технологии")
            {
                Degree = new Degree("Магистратура")
                         .AddCourse(new Course("Программирование")
                                    .AddStudent(new Student("Миша"))
                                    .AddStudent(new Student("Паша"))
                                    .AddStudent(new Student("Коля"))
                                    .AddTeacher(new Teacher("Ольга Владимировна")))
            };

            Console.WriteLine($"Программа - '{uProgram.Name}' Степень - '{uProgram.Degree.Name}'");
            foreach (var course in uProgram.Degree.Courses)
            {
                Console.WriteLine($"Курс - '{course.Name}' в степени - '{uProgram.Degree.Name}'");
                Console.WriteLine($"Кол-во студентов - '{course.Students.Count}'");
            }

            Console.ReadKey();
        }
コード例 #18
0
        public void Main(string[] args)
        {
            Student student1 = new Student("Sam", "Dolpho", DateTime.Now, string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, string.Empty);

            student1.AddGrade("A");
            student1.AddGrade("B");
            student1.AddGrade("C");
            student1.AddGrade("D");
            student1.AddGrade("F");

            Student student2 = new Student("Eric", "Chosen", DateTime.Now, string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, string.Empty);

            student2.AddGrade("F");
            student2.AddGrade("A");
            student2.AddGrade("A");
            student2.AddGrade("D");
            student2.AddGrade("A");

            Student student3 = new Student("Yorkic", "Namit", DateTime.Now, string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, string.Empty);

            student2.AddGrade("F");
            student2.AddGrade("A");
            student2.AddGrade("C");
            student2.AddGrade("D");
            student2.AddGrade("A");

            Teacher teacher = new Teacher("Dr.", "Emil", "Shoe", DateTime.Now, string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, "Information Technology");
            Course  course  = new Course("Dev204x", "Programming with C#", "Programming", 5, teacher, new ArrayList {
                student1, student2, student3
            });
            Degree   degree  = new Degree("Bachelor", "Computer Science", 400, course);
            UProgram program = new UProgram("Information Technology", new ArrayList {
                "Bachelor", "Masters"
            }, teacher, degree);

            program.Degree.Course.ListStudents();

            Console.WriteLine("Press any key to continue...");
            Console.ReadKey();
        }
コード例 #19
0
        static void Main(string[] args)
        {
            // 1- Instantiate three Student objects.
            Student student1 = new Student("John", "Snow", new DateTime(1990, 10, 22), "*****@*****.**");
            Student student2 = new Student("Jaime", "Lanyster", new DateTime(1950, 03, 12), "*****@*****.**");
            Student student3 = new Student("Walter", "White", new DateTime(1975, 12, 27), "*****@*****.**");

            // 2- Instantiate a Course object called Programming with C#.
            Course course = new Course("Programming with C#", 15);

            // 3- Add your three students to this Course object.
            course.addStudent(student1);
            course.addStudent(student2);
            course.addStudent(student3);

            // 4- Instantiate at least one Teacher object.
            Teacher teacher = new Teacher("Jessie", "Pinkman", new DateTime(1985, 04, 03), "*****@*****.**");

            // 5- Add that Teacher object to your Course object.
            course.addTeacher(teacher);

            // 6- Instantiate a Degree object, such as Bachelor.
            Degree degree = new Degree("Bachelor of Science", 250, null);

            // 7- Add your Course object to the Degree object.
            degree.Course = course;

            // 8- Instantiate a UProgram object called Information Technology.
            UProgram uProgram = new UProgram("Information Technology", "Gustavo Fring", null);

            // 9- Add the Degree object to the UProgram object.
            uProgram.Degree = degree;

            // 10- Output the information.
            Console.WriteLine("The {0} program contains the {1} degree\n", uProgram.ProgramName, degree.DegreeName);
            Console.WriteLine("The {0} degree contains the course {1}\n", degree.DegreeName, course.CourseName);
            Console.WriteLine("The {0} course contains {1} student(s)\n", course.CourseName, course.StudentsNumber);
        }
コード例 #20
0
        static void Main(string[] args)
        { //(1)
            Student Stud001 = new Student();
            Student Stud002 = new Student();
            Student Stud003 = new Student();
            //(2)
            Course ProgrammingWithCSharp = new Course();

            ProgrammingWithCSharp.CourseName = "Programming with C#";
            //(3)
            ProgrammingWithCSharp.ArrayStudent[0] = Stud001;
            ProgrammingWithCSharp.ArrayStudent[1] = Stud002;
            ProgrammingWithCSharp.ArrayStudent[2] = Stud003;
            //(4)
            Teacher Teacher001 = new Teacher();

            //(5)
            ProgrammingWithCSharp.ArrayTeacher[0] = Teacher001;
            //(6)
            Degree Bachelor = new Degree();

            Bachelor.DegreeName = "Bachelor of Science";
            //(7)
            Bachelor.SingleCourse = ProgrammingWithCSharp;
            //(8)
            UProgram InformationTechnology = new UProgram();

            InformationTechnology.Name = "Information Technology";
            //(9)
            InformationTechnology.SingleDegree = Bachelor;
            //(10)
            Console.WriteLine("The {0} program contains the {1} degree." +
                              "\nThe {1} degree contains the course {2}." +
                              "\nThe {2} course contains {3} student(s)."
                              , InformationTechnology.Name, Bachelor.DegreeName, ProgrammingWithCSharp.CourseName, Stud003.Counter);
            Console.WriteLine("{0}", ProgrammingWithCSharp.ArrayStudent[0].FirstName);
            Console.ReadKey();
        }
コード例 #21
0
ファイル: edX5.cs プロジェクト: kbuzby/edX
    public static void Main()
    {
        Student[] students = new Student[3];
        for (int i = 0; i < 3; i++)
        {
            WriteLine("Enter info for student {0}", i);
            students [i] = getInfo.forStudent();
            WriteLine(" ");
        }

        Professor[] professors = new Professor[3];
        for (int i = 0; i < 3; i++)
        {
            WriteLine("Enter info for Professor {0}", i);
            professors [i] = getInfo.forProf();
            WriteLine(" ");
        }

        Course course1 = new Course();

        course1.name       = "Programming with C#";
        course1.students   = students;
        course1.professors = professors;

        Degree newDeg = new Degree();

        newDeg.name   = "Bachelor of Science";
        newDeg.course = course1;

        UProgram newProg = new UProgram();

        newProg.name   = "Information Technology";
        newProg.degree = newDeg;

        WriteLine("The {0} program has the {1} degree", newProg.name, newProg.degree.name);
        WriteLine("The {0} degree contains the {1} course", newDeg.name, newDeg.course.name);
        WriteLine("The {0} course has {1} students enrolled", course1.name, course1.students.Length);
    }
コード例 #22
0
        static void Main(string[] args)
        {
            Person student = getStudentInformation();

            printStudentInformation(student);

            // Next line will throw an exception if uncommented (per assigment).
            //student.validateBirthday();

            Course course = Course.makeInstanceFromConsoleInput();

            Console.WriteLine();
            course.printToConsole();
            Console.WriteLine();

            UProgram uProgram = UProgram.makeInstanceFromConsoleInput();

            Console.WriteLine();
            uProgram.printToConsole();

            Console.WriteLine("Press Enter to finish...");
            Console.ReadLine();
        }
コード例 #23
0
        static void Main(string[] args)
        {
            Student student1 = new Student("Gordon", "Yang", "19890118", "Nanjing", "Jiangsu", "China", "030024");

            Student student2 = new Student("Amy", "Wang", "19890118", "Nanjing", "Jiangsu", "China", "030025");

            Student student3 = new Student("Jane", "Ma", "19890118", "Nanjing", "Jiangsu", "China", "030026");

            Course course = new Course("Programming with C#", "4", "8");
            course.EnrolledStudent[0] = student1;
            course.EnrolledStudent[1] = student2;
            course.EnrolledStudent[2] = student3;

            Teacher teacher1 = new Teacher("Tom", "Xiao", "19890118", "Nanjing", "Jiangsu", "China", "226300");
            course.Teacher[0] = teacher1;

            Degree degree = new Degree("Bachelor", "234", course);

            UProgram uprogram = new UProgram("Information Technology", "Cunhua Li", degree);

            Console.WriteLine("The {0} of {1} degree contains the course {2}", degree.DegreeName, uprogram.UprogramName, course.CourseName);
            Console.WriteLine("The {0} course contains {1} student(s)", course.CourseName, Student.NumEnrolled);
        }
コード例 #24
0
ファイル: Program.cs プロジェクト: dmmikl86/C-sharp
        private static void Main(string[] args)
        {
            Student[] students = new Student[SIZE];
            students[0] = new Student("Mich", "Dm");
            students[1] = new Student("Scott", "Liv");
            students[2] = new Student("Max", "Bill");

            Teacher[] teachers = new Teacher[SIZE];
            teachers[0] = new Teacher("Oleg", "Basilica");

            Degree degree = new Degree("Bachelor");
            UProgram uProgram = new UProgram("Information Technology");

            Course course = new Course("Programming with C#");
            course.AddStudents(students);
            course.AddTeacher(teachers[0]);
            degree.Course = course;
            uProgram.Degree = degree;

            Console.WriteLine(uProgram.ToString());
            Console.WriteLine(degree.ToString());
            Console.WriteLine(course.ToString());
        }
        public void Main(string[] args)
        {
            /*
             * Since we don't need to display student information
             * I am using empty values.
             */
            Student student1 = new Student(string.Empty, string.Empty, DateTime.Now, string.Empty, string.Empty,
                                           string.Empty, string.Empty, string.Empty, string.Empty, string.Empty);
            Student student2 = new Student(string.Empty, string.Empty, DateTime.Now, string.Empty, string.Empty,
                                           string.Empty, string.Empty, string.Empty, string.Empty, string.Empty);
            Student student3 = new Student(string.Empty, string.Empty, DateTime.Now, string.Empty, string.Empty,
                                           string.Empty, string.Empty, string.Empty, string.Empty, string.Empty);

            /*Don't need to display data using empty values*/
            Teacher teacher = new Teacher(string.Empty, string.Empty, string.Empty, string.Empty);

            Course course = new Course("Dev204x", "Programming with C#", "Programming", 5, teacher,
                                       new[] { student1, student2, student3 });
            Degree   degree  = new Degree("Bachelor", "Computer Science", 400, course);
            UProgram program = new UProgram("Information Technology", new[] { "Bachelor", "Masters" }, teacher, degree);

            var sb = new StringBuilder();

            sb.AppendFormat("The {0} program contains the {1} of {2} degree", program.Name, program.Degree.Level,
                            program.Degree.Major).AppendLine();
            sb.AppendLine();
            sb.AppendFormat("The {0} of {1} contains the course {2}", program.Degree.Level, program.Degree.Major,
                            program.Degree.Course.Title).AppendLine();
            sb.AppendLine();
            sb.AppendFormat("The {0} course contains {1} student(s)", program.Degree.Course.Title, Student.NumberOfStudents)
            .AppendLine();

            Console.WriteLine(sb.ToString());
            Console.WriteLine("Press any key to continue...");
            Console.ReadKey();
        }
コード例 #26
0
        static void Main(string[] args)
        {
            UProgram IT = new UProgram("Information Technology");

            Course ProgrammingWithCSharp = new Course("Programming With C#");

            Student mWest = new Student("Matt", "West");

            Student lWest = new Student("Lynne", "West");

            Student rWest = new Student("Riley", "West");

            Teacher ltWest = new Teacher("Logan", "West");

            ProgrammingWithCSharp.Students.Add(mWest);

            ProgrammingWithCSharp.Students.Add(lWest);

            ProgrammingWithCSharp.Students.Add(rWest);

            ProgrammingWithCSharp.Teachers.Add(ltWest);

            Degree Bachelor = new Degree("Bachelor");

            Bachelor.Courses.Add(ProgrammingWithCSharp);

            IT.DegreePrograms.Add(Bachelor);

            Console.WriteLine(IT.ProgramName);

            IT.DegreePrograms.ForEach(e => Console.WriteLine(e.DegreeName));

            Bachelor.Courses.ForEach(e => Console.WriteLine(e.CourseName));

            Console.WriteLine(ProgrammingWithCSharp.Students.Count);
        }
コード例 #27
0
        //test unit
        static void Main(string[] args)
        {
            int input = 0;

            // Create an array to hold 5 student structs.
            Student[] stArr = new Student[5];
            LabelM : welMessage();
            try
            {
                input = int.Parse(Console.ReadLine());
            }
            catch (FormatException e)
            {
                Console.WriteLine("Invalid Input please enter a valid choice");
                goto LabelM;
            }

            switch (input)
            {
            case 1:
                // Create a struct to represent a student
                Student st = new Student("Sophie", "Greene", new DateTime(1982, 12, 1),
                                         "30 Some Street", "", "Leeds", "West Yorkshire", "ZE7 3AE", "UK");
                PrintDetails(st);
                break;

            case 2:
                //Create a struct to represent a teacher
                Teacher tt = new Teacher("Manual", "Zu", new DateTime(1970, 1, 1), "30 Other Street",
                                         "", "Sheffield", "West Yorkshire", "LE7 9MN", "UK");
                PrintDetails(tt);
                break;

            case 3:
                //Create a struct to represent a program
                UProgram prog = new UProgram("Intro to Computer Science", "Some Guy", "BSc. blah blah");
                PrintDetails(prog);
                break;

            case 4:
                // Create a struct to represent a course
                Course cour = new Course("Intro hbla", 3, 9, "Mr blah Person");
                PrintDetails(cour);
                break;

            case 5:

                //Assign values to the fields in at least one of the student structs in the array
                //Using a series of Console.WriteLine() statements, output the values for the
                //student struct that you assigned in the previous step
                for (int i = 0; i < stArr.Length; i++)
                {
                    stArr[i] = new Student("Sophie", "Greene", new DateTime(1982, 12, 1), "30 Some Street", "", "Leeds", "West Yorkshire", "ZE7 3AE", "UK");
                    Console.WriteLine("student details in Array item number {0}", i);
                    PrintDetails(stArr[i]);
                }
                break;

            case 6:
                #region challenge
                //challenge: cUse an appropriate looping structure to add values to all student structs
                //in the array by prompting a user of the application to enter values for fields.
                for (int i = 0; i < stArr.Length; i++)
                {
                    stArr[i] = new Student();
                    GetInformation(out stArr[i]);
                    //array index start at zero so we add one for item number
                    Console.WriteLine("student details in Array item number {0}", i + 1);
                    PrintDetails(stArr[i]);
                }
                //challenge: create another loop to iterate over the array and write the values to the console window
                for (int i = 0; i < stArr.Length; i++)
                {
                    PrintDetails(stArr[i]);
                }
                #endregion
                break;

            case 7:
                goto LabelQ;
                break;

            default:
                Degree deg = new Degree("Bsc. A M", 72);
                PrintDetails(deg);
                break;
            }
            #region clear console
            Console.Write("Press Any Key to Continue");
            Console.ReadKey();
            Console.Clear();
            #endregion
            goto LabelM;
LabelQ:
            #region keep console window open
            Console.Write("Press Any Key to Continue");
            Console.ReadKey();
            Console.Clear();
            #endregion
        }
コード例 #28
0
ファイル: Program.cs プロジェクト: sophie-greene/Csharp
 //overload for UProgram
 static void PrintDetails(UProgram prog)
 {
     Console.WriteLine("UProgram Details");
     Console.WriteLine("Program's Name : {0}", prog.programName);
     Console.WriteLine("Department Head: {0} ", prog.departmentHead);
     Console.WriteLine("Related degrees: {0} ", prog.degrees);
     Console.WriteLine("=========");
 }
コード例 #29
0
        static void Main(string[] args)
        {
            int      option = 0;
            var      a      = "";
            String   b;
            DateTime dob;

            while (true)
            {
                Console.WriteLine("1. Enter Student Info ");
                Console.WriteLine("2. Enter Teacher Info ");
                Console.WriteLine("3. Enter Uprogram Info ");
                Console.WriteLine("4. Enter Degree Info ");
                Console.WriteLine("5. Enter Course Info \n");

                Console.WriteLine("6. Show Student Info ");
                Console.WriteLine("7. Show Teacher Info ");
                Console.WriteLine("8. Show Uprogram Info ");
                Console.WriteLine("9. Show Degree Info ");
                Console.WriteLine("10. Show Course Info \n");

                Console.WriteLine("11. Clear History");
                Console.WriteLine("12. Input from file");

                Console.WriteLine("0. Exit ");



                a = Console.ReadLine();
                try
                {
                    option = Int32.Parse(a);
                }
                catch (Exception e)
                {
                    Console.WriteLine("Please give a valid input");
                }

                if (option == 1)
                {
                    Student student = new Student();

                    Console.WriteLine("#" + Student.Count + "\n");
                    Console.WriteLine("Enter First Name: ");
                    a = Console.ReadLine();
                    student.setFirstName(a);
                    Console.WriteLine("Enter Last Name: ");
                    a = Console.ReadLine();
                    student.setLastName(a);
                    Console.WriteLine("Enter Date of Birth: ");
                    a = Console.ReadLine();
                    try
                    {
                        dob = DateTime.Parse(a);
                    }
                    catch (Exception e)
                    {
                        Console.WriteLine(e);
                    }
                    a = Console.ReadLine();
                    Console.WriteLine("Enter Address Line 01: ");
                    student.setAddress01(a);

                    a = Console.ReadLine();
                    Console.WriteLine("Enter Address Line 02: ");
                    student.setAddress02(a);

                    a = Console.ReadLine();
                    Console.WriteLine("Enter City: ");
                    student.setCity(a);

                    a = Console.ReadLine();
                    Console.WriteLine("Enter State: ");
                    student.setState(a);

                    a = Console.ReadLine();
                    Console.WriteLine("Enter Zip/Postal: ");
                    student.setZip(a);

                    a = Console.ReadLine();
                    Console.WriteLine("Enter Coutnry: ");
                    student.setCountry(a);
                    student.setStudentRecord();
                }
                else if (option == 2)
                {
                    Teacher teacher = new Teacher();
                    Console.WriteLine("#" + Teacher.Count + "\n");

                    Console.WriteLine("Enter First Name: ");
                    a = Console.ReadLine();
                    teacher.setFirstName(a);
                    Console.WriteLine("Enter Last Name: ");
                    a = Console.ReadLine();
                    teacher.setLastName(a);
                    Console.WriteLine("Enter Date of Birth: ");
                    a = Console.ReadLine();

                    try
                    {
                        dob = DateTime.Parse(a);
                    }
                    catch (Exception e)
                    {
                        Console.WriteLine(e);
                    }

                    Console.WriteLine("Enter Address Line 01: ");
                    a = Console.ReadLine();
                    teacher.setAddress01(a);


                    Console.WriteLine("Enter Address Line 02: ");
                    a = Console.ReadLine();
                    teacher.setAddress02(a);

                    a = Console.ReadLine();
                    Console.WriteLine("Enter City: ");
                    teacher.setCity(a);


                    Console.WriteLine("Enter State: ");
                    a = Console.ReadLine();
                    teacher.setState(a);


                    Console.WriteLine("Enter Zip/Postal: ");
                    a = Console.ReadLine();
                    teacher.setZip(a);


                    Console.WriteLine("Enter Coutnry: ");
                    a = Console.ReadLine();
                    teacher.setCountry(a);

                    teacher.setTeacherRecord();
                }

                else if (option == 3)
                {
                    UProgram upr = new UProgram();
                    Console.WriteLine("#" + UProgram.Count + "\n");

                    Console.WriteLine("Enter Program Name: ");
                    a = Console.ReadLine();
                    upr.setProgramName(a);

                    Console.WriteLine("Enter Department Head: ");
                    a = Console.ReadLine();
                    upr.setDepartmentHead(a);

                    Console.WriteLine("Enter Degrees: ");
                    a = Console.ReadLine();
                    upr.setDegrees(a);
                    upr.setRecord();
                }

                else if (option == 4)
                {
                    Degree degree = new Degree();
                    Console.WriteLine("#" + Degree.Count + "\n");

                    Console.WriteLine("Enter Degree Name: ");
                    a = Console.ReadLine();
                    degree.setDegreeName(a);

                    Console.WriteLine("Enter Credits Required: ");
                    a = Console.ReadLine();
                    degree.setCreditsRequired(a);
                    degree.setRecord();
                }
                else if (option == 5)
                {
                    Course course = new Course();
                    Console.WriteLine("#" + Course.Count + "\n");

                    Console.WriteLine("Enter Course Name: ");
                    a = Console.ReadLine();
                    course.setCourseName(a);

                    Console.WriteLine("Enter Credits: ");
                    a = Console.ReadLine();
                    course.setCredits(a);

                    Console.WriteLine("Enter Duration In a Week: ");
                    a = Console.ReadLine();
                    course.setDuration(a);

                    Console.WriteLine("Enter Teacher: ");
                    a = Console.ReadLine();
                    course.setTeacher(a);
                    course.setRecord();
                }
                else if (option == 6)
                {
                    Student student = new Student();
                    student.showInfo();
                }
                else if (option == 7)
                {
                    Teacher teacher = new Teacher();
                    teacher.showInfo();
                }
                else if (option == 8)
                {
                    UProgram uprogram = new UProgram();
                    uprogram.showUProgramInfo();
                }
                else if (option == 9)
                {
                    Degree degree = new Degree();
                    degree.showDegrees();
                }
                else if (option == 10)
                {
                    Course course = new Course();
                    course.showCourseInformation();
                }
                else if (option == 11)
                {
                    String s = "";
                    Console.WriteLine("1. Student Info");
                    Console.WriteLine("2. Teacher Info");
                    Console.WriteLine("3. UProgram Info");
                    Console.WriteLine("4. Degree Info");
                    Console.WriteLine("5. Course Info");

                    a      = Console.ReadLine();
                    option = Int32.Parse(a);

                    if (option == 1)
                    {
                        Student st = new Student();
                        st.Clear();
                    }
                    else if (option == 2)
                    {
                        Teacher tc = new Teacher();
                        tc.Clear();
                    }
                    else if (option == 3)
                    {
                        UProgram up = new UProgram();
                        up.Clear();
                    }
                    else if (option == 4)
                    {
                        Degree dg = new Degree();
                        dg.Clear();
                    }
                    else if (option == 5)
                    {
                        Course cs = new Course();
                        cs.Clear();
                    }
                }
                else if (option == 12)
                {
                    Console.WriteLine("1. Student info");
                    Console.WriteLine("2. Teacher info");
                    Console.WriteLine("3. UProgram info");
                    Console.WriteLine("4. Degree info");
                    Console.WriteLine("5. Course info");

                    a      = Console.ReadLine();
                    option = Int32.Parse(a);

                    if (option == 1)
                    {
                        Console.WriteLine("Enter file name from where to take input from: ");
                        String s = Console.ReadLine();

                        Student student = new Student();
                        student.InputFromFile(s);
                    }
                    else if (option == 2)
                    {
                        Console.WriteLine("Enter file name from where to take input from: ");
                        String s = Console.ReadLine();

                        Teacher student = new Teacher();
                        student.InputFromFile(s);
                    }
                    else if (option == 3)
                    {
                        Console.WriteLine("Enter file name from where to take input from: ");
                        String s = Console.ReadLine();

                        UProgram student = new UProgram();
                        student.InputFromFile(s);
                    }
                    else if (option == 4)
                    {
                        Console.WriteLine("Enter file name from where to take input from: ");
                        String s = Console.ReadLine();

                        Degree student = new Degree();
                        student.InputFromFile(s);
                    }
                    else if (option == 5)
                    {
                        Console.WriteLine("Enter file name from where to take input from: ");
                        String s = Console.ReadLine();

                        Course student = new Course();
                        student.InputFromFile(s);
                    }
                }
                else
                {
                    break;
                }
            }
            Console.WriteLine("Press any key to close the program...");
            Console.ReadKey();
        }
コード例 #30
0
ファイル: Program.cs プロジェクト: sophie-greene/Csharp
        //test unit
        static void Main(string[] args)
        {
            int input = 0;
            // Create an array to hold 5 student structs.
            Student[] stArr = new Student[5];
            LabelM: welMessage();
            try
            {
                input = int.Parse(Console.ReadLine());
            }
            catch (FormatException e)
            {
                Console.WriteLine("Invalid Input please enter a valid choice");
                goto LabelM;
            }

            switch (input)
            {
                case 1:
                    // Create a struct to represent a student
                    Student st = new Student("Sophie", "Greene", new DateTime(1982, 12, 1),
                        "30 Some Street", "", "Leeds", "West Yorkshire", "ZE7 3AE", "UK");
                    PrintDetails(st);
                    break;
                case 2:
                    //Create a struct to represent a teacher
                    Teacher tt = new Teacher("Manual", "Zu", new DateTime(1970, 1, 1), "30 Other Street",
                        "", "Sheffield", "West Yorkshire", "LE7 9MN", "UK");
                    PrintDetails(tt);
                    break;
                case 3:
                    //Create a struct to represent a program
                    UProgram prog = new UProgram("Intro to Computer Science", "Some Guy", "BSc. blah blah");
                    PrintDetails(prog);
                    break;
                case 4:
                    // Create a struct to represent a course
                    Course cour = new Course("Intro hbla", 3, 9, "Mr blah Person");
                    PrintDetails(cour);
                    break;
                case 5:

                    //Assign values to the fields in at least one of the student structs in the array
                    //Using a series of Console.WriteLine() statements, output the values for the
                    //student struct that you assigned in the previous step
                    for (int i = 0; i < stArr.Length; i++)
                    {
                        stArr[i] = new Student("Sophie", "Greene", new DateTime(1982, 12, 1), "30 Some Street", "", "Leeds", "West Yorkshire", "ZE7 3AE", "UK");
                        Console.WriteLine("student details in Array item number {0}", i);
                        PrintDetails(stArr[i]);
                    }
                    break;
                case 6:
                    #region challenge
                    //challenge: cUse an appropriate looping structure to add values to all student structs
                    //in the array by prompting a user of the application to enter values for fields.
                    for (int i = 0; i < stArr.Length; i++)
                    {
                        stArr[i] = new Student();
                        GetInformation(out stArr[i]);
                        //array index start at zero so we add one for item number
                        Console.WriteLine("student details in Array item number {0}", i + 1);
                        PrintDetails(stArr[i]);
                    }
                    //challenge: create another loop to iterate over the array and write the values to the console window
                    for (int i = 0; i < stArr.Length; i++)
                    {
                        PrintDetails(stArr[i]);
                    }
                    #endregion
                    break;
                case 7:
                    goto LabelQ;
                    break;
                default:
                    Degree deg = new Degree("Bsc. A M", 72);
                    PrintDetails(deg);
                    break;
            }
            #region clear console
            Console.Write("Press Any Key to Continue");
            Console.ReadKey();
            Console.Clear();
            #endregion
            goto LabelM;
            LabelQ:
            #region keep console window open
            Console.Write("Press Any Key to Continue");
            Console.ReadKey();
            Console.Clear();
            #endregion
        }
コード例 #31
0
ファイル: edX4.cs プロジェクト: kbuzby/edX
 public static void programInfo(UProgram prog)
 {
     WriteLine("The {0} program head is {1}, has the degrees: {2}, which are taught by: {3}", prog.name, prog.head, prog.degrees, prog.faculty);
 }
コード例 #32
0
ファイル: Program.cs プロジェクト: sophie-greene/Csharp
 public static UProgram makeInstanceFromConsoleInput()
 {
     UProgram program = new UProgram();
     program.fillFromConsoleInput();
     return program;
 }
コード例 #33
0
ファイル: Program.cs プロジェクト: sophie-greene/Csharp
 //overload for UProgram
 static void GetInformation(out UProgram prog)
 {
     Console.WriteLine("Enter the Prorgam's Name: ");
     prog.programName = Console.ReadLine();
     Console.WriteLine("Enter the department Head's name");
     prog.departmentHead = Console.ReadLine();
     Console.WriteLine("Enter the degrees related to the Program");
     prog.degrees = Console.ReadLine();
 }