static void Main(string[] args) { Person person = new Person(); person.Firstname = "Kirsi"; person.Lastname = "Kernel"; person.Age = 35; person.Address = "Piippukatu 2"; person.Phonenumber = "02001215"; Console.WriteLine(person.ToString()); Teacher teacher = new Teacher("Jussi", "Konsoli", "D456"); teacher.Address = "Piippukatu1"; teacher.Age = 40; teacher.Phonenumber = "010-541256"; Console.WriteLine(teacher.ToString()); Student student = new Student("Juuso", "Jokio"); teacher.Address = "Piippukatu 66"; teacher.Age = 21; teacher.Phonenumber = "020-541256"; Console.WriteLine(student.ToString()); Console.WriteLine("Press enter key to continue..."); Console.ReadLine(); }
private void create_btn_Click(object sender, EventArgs e) { Element el = new Element(); if (el.ShowDialog() == DialogResult.OK) { IPersonality ip; if (el.isStudent) { ip = new Person.Student() { Name = el.PersonName, Age = int.Parse(el.Age), TotalMark = int.Parse(el.TotalMark) }; } else { ip = new Person.Person() { Name = el.PersonName, Age = int.Parse(el.Age) }; } ip.propertyChanged += ShowProperty; band.Add(ip); listBox1.Items.Add(ip.ToString()); } }
public Student addS(Student s) { int count = 0; string className; Console.Write("\nWhat is the first name? "); s.Fname = Console.ReadLine(); Console.Write("\nWhat is the last name? "); s.Lname = Console.ReadLine(); Console.Write("\nHow many class were taken? "); count = Convert.ToInt32(Console.ReadLine()); for(int i = 0; i < count; i++) { Console.Write("\nWhat is the name of the class? "); className = Console.ReadLine(); s.ClassesTaken.Add(className); Console.Write("\nWhat was the grade for " + className); s.Grades.Add(Convert.ToChar(Console.ReadLine())); } return s; }
public bool IsOlderThan(Student otherStudent) { DateTime firstStudentDate = this.BirthDate; DateTime secondStudentDate = otherStudent.BirthDate; bool isOlder = false; if (firstStudentDate > secondStudentDate) { isOlder = true; } return isOlder; }
static void Main(string[] args) { Person person = new Person(); person.FirstName = "Hermanni"; person.LastName = "Hiiri"; person.Age = 96; person.Address = "Hiiriniemenkatu 6 b"; person.PhoneNumber = "999"; Console.WriteLine(person.ToString()); Teacher teacher = new Teacher("Kalle","Konsoli","D456"); teacher.Address = "Piippukatu 1"; teacher.Age = 54; teacher.PhoneNumber = "010-888 9000"; Console.WriteLine(teacher.ToString()); Student student = new Student("Pekka", "Pikseli", "H8219"); student.Address = "Kotipesä 1 b"; student.Age = 22; student.PhoneNumber = "020202"; Console.WriteLine(student.ToString()); Console.ReadLine(); }
public void searchS(Student[] s) { string searchF, searchL; Console.Write("\nWhat is the first name? "); searchF = Console.ReadLine(); Console.Write("\nWhat is the last name? "); searchL = Console.ReadLine(); for(int i = 0; i < s.Length; i++) { if((searchF == s[i].Fname) && (searchL == s[i].Lname)) { printStudent(s[i]); } } }
public void printStudent(Student s) { Console.WriteLine("\nNAME: " + s.Fname + " " + s.Lname); Console.WriteLine("\nCLASSES: "); foreach(object i in s.ClassesTaken) { Console.Write(s.ClassesTaken); } Console.WriteLine("\nGRADES: "); foreach(object i in s.Grades) { Console.Write(s.Grades); } }
public void menu() { string choice, choice2, personType; int indexE = 0; int indexS = 0; Employee[] e = new Employee[10]; Student[] s = new Student[10]; for(int i = 0; i < e.Length; i++) { e[i] = new Employee(); } e = initEmployee(e); indexE = 4; for (int i = 0; i < s.Length; i++) { s[i] = new Student(); } s = initStudent(s); indexS = 4; Console.WriteLine("\nWritten by Vincent Chui" + "\nCIS 23" + "\nLab 2" + "\nFall 2015"); do { Console.Write("\nAdd" + "\nSearch" + "\nPrint" + "\nEnter choice: "); choice = Console.ReadLine().ToLower(); switch (choice) { case "add": do { Console.Write("\nEmployee or Student? "); personType = Console.ReadLine().ToLower(); if((personType != "employee") || (personType != "student")) { Console.WriteLine("\nPlease input employee or student"); } } while ((personType != "employee") || (personType != "student")); if (personType == "employee") { addE(e[indexE]); } else { addS(s[indexS]); } break; case "search": do { Console.Write("\nemployee or student: "); choice2 = Console.ReadLine().ToLower(); if (choice2 == "employee") { searchE(e); } else if (choice2 == "student") { searchS(s); } else { Console.WriteLine("\nINVALID INPUT"); } } while((choice2 != "employee") || (choice2 != "student")); break; case "print": break; case "quit": break; default: Console.WriteLine("\nINVALID INPUT"); break; } } while (choice != "quit"); }
public Student[] initStudent(Student[] s) { return s; }