Example #1
0
        static void Main(string[] args)
        {
            Import();

            PayRoll payroll = new PayRoll();

            payroll.PayAll();

            var students = new List <Student>();

            while (true)
            {
                var newStudent = new Student();

                newStudent.Name  = Classroom.Console.Ask("Student Name: ");
                newStudent.Grade = int.Parse(Classroom.Console.Ask("Student Grade: "));
                newStudent.email = Classroom.Console.Ask("Student Email: ");
                students.Add(newStudent);
                Student.Count++;
                Console.WriteLine("Number of Students: {0}", Student.Count);

                Console.Write("Add another student? (y/n)");
                if (Console.ReadLine() != "y")
                {
                    break;
                }
            }

            foreach (var student in students)
            {
                Console.WriteLine("Student name: {0} Student Grade: {1}", student.Name, student.Grade);
            }
        }
Example #2
0
        static void Main(string[] args)
        {
            PayRoll payRoll = new PayRoll();

            payRoll.PayAll();

            var adding = true;

            while (adding)
            {
                try
                {
                    var newStudent = new student();

                    newStudent.Name = Util.Console.Ask("Student Name: ");

                    newStudent.Grade = Util.Console.AskInt("Student Grade: ");

                    newStudent.School = (school)Util.Console.AskInt("School Name (type the corresponding number):\n 0: Hogwarts High \n 1: Harvard \n 2: MIT \n)");

                    newStudent.Birthday = Util.Console.Ask("Student Birthday: ");

                    newStudent.Address = Util.Console.Ask("Student Address: ");

                    newStudent.Phone = Util.Console.AskInt("Student phone Number: ");

                    students.Add(newStudent);
                    student.Count++;
                    Console.WriteLine("Student Count: {0}", student.Count);


                    Console.WriteLine("Add another? y/n");

                    if (Console.ReadLine() != "y")
                    {
                        adding = false;
                    }
                }



                catch (FormatException msg)
                {
                    Console.WriteLine(msg.Message);
                }
                catch (Exception)
                {
                    Console.WriteLine("Error adding student, Please try again");
                }
            }

            foreach (var student in students)

            {
                Console.WriteLine("Name: {0}, Grade: {1} ", student.Name, student.Grade);
            }
            Exports();
            Console.ReadKey();
        }