static void Main(string[] args) { Logger.Log("Tracker started", priority: 0); PayRoll payroll = new PayRoll(); payroll.PayAll(); var adding = true; while (adding) { try { Logger.Log("Adding new student"); 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"); } } ShowGrade("Tom"); foreach (var student in students) { Console.WriteLine("Name: {0}, Grade: {1}", student.Name, student.Grade); } Exports(); }
static void Main(string[] args) { PayRoll payroll = new PayRoll(); payroll.PayAll(); //Setting the default value to true var adding = true; while (adding) { try { //Instantiating a new student object to access and assign its properties var newStudent = new Student { Name = Util.Console.Ask("Student Name: "), Grade = Util.Console.AskInt("Student Grade: "), School = (School)Util.Console.AskInt("School name (type corresponding number): \n 0: Reed College \n 1: PSU \n 2: OSU \n"), Birthday = Util.Console.Ask("Student Birthday: "), Address = Util.Console.Ask("Student Address: "), Phone = Util.Console.AskInt("Student Phone: ") }; //Adding students to the newStudent object students.Add(newStudent); //Accessing the count property created in the student class to keep track of student count Student.Count++; Console.WriteLine("Student Count: {0}", Student.Count); Console.WriteLine("Add another? y/n"); if (Console.ReadLine() != "y") { adding = false; } } //Using a custom exception from the utility class catch (FormatException msg) { Console.WriteLine(msg.Message); } catch (Exception) { Console.WriteLine("Error adding student, please try again. "); } } //This foreach loop prints the newStudents properties for each new student created foreach (var student in students) { Console.WriteLine("Name: {0}, Grade: {1}", student.Name, student.Grade); } //Calling the export method to display what schools will get records Exports(); }
static void Main(string[] args) { Logger.Log("Tracker started", priority: 0); PayRoll payroll = new PayRoll(); payroll.PayAll(); bool adding = true; while (adding) { try { Logger.Log("Adding new student"); Student newStudent = new Student(); newStudent.Name = Util.Console.Ask("Name: "); newStudent.Grade = Util.Console.AskInt("Grade: "); newStudent.School = (School)Util.Console.AskInt("School ID: \n(0:Hogwarts High, 1:Harvard High, 2:Yael High)\n"); newStudent.Birthday = Util.Console.Ask("Birthday: "); newStudent.Address = Util.Console.Ask("Address: "); newStudent.Phone = Util.Console.Ask("Phone Number: "); students.Add(newStudent); Student.Count++; Console.WriteLine("Student #{0}", Student.Count); if (Util.Console.Ask("Another? [Y/n]\n").ToLower() != "y") { adding = false; } } catch (FormatException msg) { Console.WriteLine(msg.Message); } catch (Exception) { Console.WriteLine("Error, try again!"); } } ShowGrade("Tom"); foreach (Student student in students) { Console.WriteLine("{0}: {1}", student.Name, student.Grade); } Exports(); }
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 correspnding number: \n 0: MahoutoKorro \n 1: Hogwarts \n 2: Ilvermorny \n 3:Castle Bruxo \n 4: Uagadou\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.Write("Error, please re-enter: "); } } foreach (var student in students) { Console.WriteLine("Name: {0} lives at {3} and was born on: {2} his/her Grade is: {1}", student.Name, student.Grade, student.Birthday, student.Address); } Exports(); }
static void Main(string[] args) { ///Console.WriteLine("Hello World!"); /// 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 corresponding number): \n 0:Hogwards \n 1:Howards \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); } Export(); }
static void Main(string[] args) { // we call our import function to see dat student data was imported Import(); var studentNames = new List <string>(); var studentGrades = new List <int>(); var adding = true; // we create a payroll instance using our payroll class // we then access the PayAll() method PayRoll payRoll = new PayRoll(); payRoll.PayAll(); while (adding) { // adding a try/catch block try { // we create a new object instance of type student var newStudent = new Student(); // Console.Write("Student Name: "); // newStudent.Name = (Console.ReadLine()); // refactored the above code to Util class function newStudent.Name = Util.Console.Ask("Student Name: "); // divide by zero code to test other exception //var z = 0; //var a = 1 / z; // refactored the above code to Util class function // it's also refactored with exceptions to use tryparse //the out parameter will give us the result newStudent.Grade = Util.Console.AskInt("Student Grade: "); // we use casting to convert the integer into an enumerator newStudent.School = (School)Util.Console.AskInt("School Name: (type corresponding number): \n 0: Hogwarts High \n 1: Harvard \n 2:MIT \n) "); // refactored the above code to Util class functionde newStudent.Birthday = Util.Console.Ask("Student Birthday: "); // refactored the above code to Util class function newStudent.Address = Util.Console.Ask("Student Address: "); //refactored the code above to use the new traditional variable newStudent.Phone = Util.Console.AskInt("Student Phone Number: "); students.Add(newStudent); // accessing the static variable through the class Student.Count++; // we output the student count for testing Console.WriteLine("Student Count: {0}", Student.Count); Console.WriteLine("Add another? y/n"); if (Console.ReadLine() != "y") { adding = false; } } // this exception has to come before the more generic ones // we receive the message from console class catch (FormatException msg) { // this error message displays if letter is typed in where number is supposed to be Console.WriteLine(msg.Message); } catch (Exception) { // this error message displays if the program fails Console.WriteLine("Error Adding Student please try again"); } foreach (var student in students) { Console.WriteLine("Name: {0}, Grade: {1}", student.Name, student.Grade); } Exports(); } }
static void Main(string[] args) { PayRoll payroll = new PayRoll(); payroll.PayAll(); Graduate graduate = new Graduate(); var adding = true; while (adding) { try { var newStudent = new Student(); var newGrad = new Graduate(); 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++; graduates.Add(newGrad); Console.WriteLine("Student Count: {0}", Student.Count); Console.WriteLine("Add another? y/n"); if (Console.ReadLine() != "y") { adding = false; } /*Graduate graduate = new Graduate(); * graduate.AllGrads();*/ } 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); graduate.AllGrads(); } /* foreach (var graduate1 in graduates) * { * Console.WriteLine("Name: {0} ", ); * }*/ Exports(); foreach (var student in students) { Console.Write("Name: {0} ", student.Name); graduate.AllGrads(); } }
static void Main(string[] args) { Logger.Log("Tracker started", priority: 0); PayRoll payroll = new PayRoll(); payroll.PayAll(); var adding = true; while (adding) { try { Logger.Log("Adding New Student"); var newStudent = new Student(); newStudent.Name = Util.Console.Ask("Name: "); newStudent.Grade = Util.Console.AskInt("Grade: "); newStudent.School = (EnumSchool)Util.Console.AskInt("School (type the corresponding number): \n 0: Hogwarts\n 1: Harvard\n 2: MIT\n"); newStudent.Birthday = Util.Console.Ask("Birthday: "); newStudent.Address = Util.Console.Ask("Address: "); newStudent.Phone = Util.Console.AskLong("Phone Number: "); students.Add(newStudent); Student.Count++; Console.Write("Add another? y/n "); if (Console.ReadLine().ToLower() != "y") { adding = false; } Console.Clear(); } catch (FormatException msg) { Console.Clear(); Console.WriteLine(msg.Message); } catch (Exception) { Console.Clear(); Console.WriteLine("Error adding student, Please try again"); } } try { ShowGrade("Tom"); } catch (Exception) { Console.WriteLine("Student Tom Not Found"); } foreach (var student in students) { Console.WriteLine("Name: {0}, Grade: {1}", student.Name, student.Grade); } Console.WriteLine(Student.Count + (Student.Count == 1 ? " student" : " students")); Exports(); }