static void Main(string[] args) { var engine = new SchoolEngine(); engine.Initialize(); engine.PrintCourses(); }
static void Main(string[] args) { var engine = new SchoolEngine(); engine.Initialize(); var objList = engine.GetSchoolObjects(); var listIPlace = from obj in objList where obj is IPlace select(IPlace) obj; //engine.school.ClearPlace(); }
static void Main(string[] args) { AppDomain.CurrentDomain.ProcessExit += DoEventAction; AppDomain.CurrentDomain.ProcessExit += (object sender, EventArgs e) => Beep(100, 100, 1); var engine = new SchoolEngine(); engine.Initialize(); PrintTitle("Bienvenidos a la escuela"); var reporter = new Reporter(engine.GetObjectsDictionary()); var evaluationList = reporter.GetEvaluationsList(); var subjectList = reporter.GetSubjectList(); var evaluationBySubjectList = reporter.GetEvaluationDictionaryBySubject(); Dictionary <string, IEnumerable <StudentAverage> > averageScoreBySubject = reporter.GetScoreStudentsBySubject(); var topAveragesPerSubject = reporter.GetTopStudentsBySubjects(averageScoreBySubject); getEvaluationByConsole(); }
static void Main(string[] args) { AppDomain.CurrentDomain.ProcessExit += EventAction; AppDomain.CurrentDomain.ProcessExit += (o, a) => Printer.Beep(100, 1000, 1); var engine = new SchoolEngine(); engine.Initialize(); Printer.WriteTitle("Welcome to the School"); //Printer.Beep(10000,500, 10); printSchoolCourses(engine.School); var objectList = engine.GetSchoolObjects(); // engine.School.CleanPlace(); Dictionary <int, string> dictionary = new Dictionary <int, string>(); dictionary.Add(10, "Alfredo"); dictionary.Add(23, "Blue"); foreach (var key in dictionary) { WriteLine($"key: {key.Key} Value: {key.Value}"); } Printer.WriteTitle("Dictionary access"); dictionary[0] = "Moss"; WriteLine(dictionary[0]); Printer.WriteTitle("Another dictionary"); var dic = new Dictionary <string, string>(); dic["Luna"] = "Cuerpo celeste"; WriteLine(dic["Luna"]); dic["Luna"] = "Main charcater"; WriteLine(dic["Luna"]); var dictmp = engine.getObjectDictionary(); engine.PrintDictionary(dictmp, true); }
static void Main(string[] args) { // How to make an event listener. ProcessExit is name of event, EventAction is the callback // we can use lambda for the callback AppDomain.CurrentDomain.ProcessExit += EventAction; AppDomain.CurrentDomain.ProcessExit += (obj, e) => Printer.DrawTitle("Printer Line!"); // Engine initialization var engine = new SchoolEngine(); engine.Initialize(); Printer.DrawTitle("Welcome to the school!"); // Print PrintCourses(engine.School); // Obtain Core Objects with params to loop conditionally var objList = engine.ObtainCoreObjects( out int examsCounter, out int coursesCounter, out int subjectsCounter, out int studentsCounter ); // using Linq to obtain list of addresses var iAddressList = from obj in objList where obj is IAddress select(IAddress) obj; engine.School.ClearAddress(); #region Studying dictionaries // Dictionary /* * // We can set ket and value pairs like --> <int (key), string (value)> * Dictionary<int, string> dictionary = new Dictionary<int, string>(); * * // Ways to update it: * dictionary[0] = "Test 0"; * dictionary.Add(10, "Test"); * dictionary.Add(23, "Test 2"); * Printer.DrawTitle("Dictionaries"); * * // Ways to access the contents * * foreach (var keyValPair in dictionary) * { * // Like this * WriteLine($"Key: {keyValPair.Key}, Value: {keyValPair.Value}"); * } * // Like this * WriteLine(dictionary[0]); * * // We can set the key as a string * * var otherDic = new Dictionary<string, string>(); * otherDic["Moon"] = "What we see at the night in the sky... reflecting the sun's light"; * WriteLine($"Moon: {otherDic["Moon"]}"); * // Can we change it? No, we can replace it. Keys are UNIQUE * otherDic["Moon"] = "Another description"; */ // Implementing the dictionary used for the school var dictionary = engine.GetObjectsDictionary(); engine.PrintDictionary(dictionary, true); #endregion /* * // Polymorphism tests * Printer.DrawLine(); * Printer.DrawLine(); * Printer.DrawLine(); * Printer.DrawTitle("Polymorphism tests:"); * * var studentTest = new Student("Pablito"); * BaseSchool ob = studentTest; * * WriteLine("Student: Polymorphism works?"); * WriteLine($"{studentTest.GetType()}"); * WriteLine($"{ob.GetType()}"); */ // Exams Reporter var reporter = new Reporter(engine.GetObjectsDictionary()); var examsList = reporter.GetExamsList(); // Capture Exam Exam myExam; string name; string student; string result; Printer.DrawTitle("Capturing exam by the console..."); WriteLine("Please provide the name of the exam."); Printer.PressEnter(); name = ReadLine(); WriteLine("Please provide the student name of the exam:"); Printer.PressEnter(); student = ReadLine(); WriteLine("Please provide the result of the exam:"); Printer.PressEnter(); result = ReadLine(); if (string.IsNullOrWhiteSpace(name) || string.IsNullOrWhiteSpace(student) || string.IsNullOrWhiteSpace(result)) { throw new ArgumentException("The value provided cannot be empty"); } myExam = new Exam(name, student, double.Parse(result)); WriteLine($"{myExam.Name}, {myExam.StudentName}, {myExam.Result}"); }
static void Main(string[] args) { var engine = new SchoolEngine(); engine.Initializer(); Printer.WriteTitle("Welcome to the School"); //Printer.DrawLine(20); //Printer.Beep(10000, total:10); printSchoolCourses(engine.School); //School mySchool = new School(); //var school = new School("My Success Online Academy", 2012, TypeSchool.Primary, //country: "Colombia", city: "Medellin"); //school.Country = "Colombia"; //school.City = "Medellin"; //Console.WriteLine(school.Name); //school.typeSchool = TypeSchool.Primary; //Console.WriteLine(school); /*var arrayCourses = new Courses[3]; * arrayCourses[0] = new Courses() * { * Name = "101" * }; * * var course2 = new Courses() * { * Name = "201" * }; * * arrayCourses[1] = course2; * * arrayCourses[2] = new Courses() * { * Name = "301" * };*/ //Uso de arreglos: /*school.Courses = new Course[]{ * new Course() {Name = "101"}, * new Course() {Name = "201"}, * new Course {Name = "301"} * }; */ //newCollection.Clear(); //Borra todos los elementos de una colección generica. /* * Course tmp = new Course{Name = "101 Vacations", workingday = TypeWorkingDay.Night}; * //Las colecciones nos permiten agregar, quitar elemntos, etc. * //Adicionar otra lista: * school.Courses.AddRange(newCollection); * school.Courses.Add(tmp); * printSchoolCourses(school); * //WriteLine("Course.Hash = " + tmp.GetHashCode()); //Para eliminar el framework mira el HasCode * * Predicate <Course> myAlgorithm = Predicating; * //school.Courses.RemoveAll(myAlgorithm); //Manera de borrar (mirar metodo predicate) * //school.Courses.Remove(tmp); * school.Courses.RemoveAll(delegate (Course cour) //Creacion de delegado (remueve todos los que tengan 301 en el nombre) * { * return cour.Name == "301"; * }); //Los que tengan 301 retorna true y los borra * */ //Expresiones lambda: //school.Courses.RemoveAll((cour) => cour.Name == "501" && cour.workingday == TypeWorkingDay.Day); //Console.WriteLine(school); //System.Console.WriteLine("================="); /*Console.WriteLine(arrayCourses[0].Name + ", " + arrayCourses[0].UniqueId); * Console.WriteLine($"{arrayCourses[1].Name}, {arrayCourses[1].UniqueId}"); * Console.WriteLine("Press intro..."); * Console.ReadLine(); * Console.WriteLine(arrayCourses[5]); * //Console.WriteLine(course3); */ //PrintNumbers(arrayCourses); //school.Courses = new Course[0]; //printSchoolCourses(school); }