예제 #1
0
        static void Main(string[] args)
        {
            //Class objects creation from base and derived classes
            Person myPerson = new Person("Tony", "Rosella" ,"123 way St.", "444-5555");
            Student myStudent = new Student("Joe", "Bob", "321 North Ave.", "321-123-4567", 3.45, "Computer Science", "11/10/16");
            Employee myEmployee = new Employee("Jake", "Smith", "456 Sea Dr.", "321-867-5309", "42345", "Health");
            Instructor myInstructor = new Instructor("Shela", "Roberts", "323 Fruit way", "323-456-3412", "333", "8-4 pm");

            //Displays info for each class
            Console.WriteLine(myPerson);
            Console.WriteLine(myStudent);
            Console.WriteLine(myEmployee);
            Console.WriteLine(myInstructor);
        }
예제 #2
0
 public void Add(string idName, Person myPerson)
 {
     Dictionary.Add(idName, myPerson);
 }
예제 #3
0
 private People(Person persons)
 {
     person = persons;
 }
예제 #4
0
 public object Clone()
 {
     Person person = new Person();
     return person;
 }
예제 #5
0
 static void Main(string[] args)
 {
     UserControl usercontrol = new UserControl();
     Person namesList = new Person();
     People people = new People();
     DateTime t = DateTime.Now;
     people.Add("Vlad", new Person("Vlad", 28));
     people.Add("Alina", new Person("Alina", 24));
     people.Add("Ivan", new Person("Ivan", 31));
     people.Add("Luda", new Person("Ludmila", 21));
     people.Add("Piter", new Person("Piter", 31));
     bool isExit = false;
     string input;
     Instruction();
     while (!isExit)
     {
         input = Console.ReadLine();
         Enum.TryParse(input, true, out usercontrol);
         switch (usercontrol)
         {
             case UserControl.Exercise1:
                 Console.WriteLine("Solve of {0}", UserControl.Exercise1);
                 Exercise1 exercise1 = new Exercise1();
                 exercise1.Show();
                 Console.WriteLine(namesList["Vlad"].Name);
                 foreach (DictionaryEntry personEntry in people)
                 {
                    Console.WriteLine("Person {0} ({1} years old)", ((Person)personEntry.Value).Name, ((Person)personEntry.Value).Age);
                 }
                 break;
             case UserControl.Exercise2:
                 Console.WriteLine("Solve of {0}", UserControl.Exercise2);
                 Exercise2 exercise2 = new Exercise2();
                 exercise2.Show();
                 Console.WriteLine("{0} older then {1}: {2}",
                     namesList["Vlad"].Name, namesList["Alina"].Name, namesList["Vlad"] > namesList["Alina"]);
                 break;
             case UserControl.Exercise3:
                 Console.WriteLine("Solve of {0}", UserControl.Exercise3);
                 Exercise3 exercise3 = new Exercise3();
                 exercise3.Show();
                 people.GetOldest();
                 break;
             case UserControl.Exercise4:
                 Console.WriteLine("Solve of {0}", UserControl.Exercise4);
                 Exercise4 exercise4 = new Exercise4();
                 exercise4.Show();
                 People people1 = new People();
                 People people2 = (People)people1.Clone();
                 people1 = people;
                 Console.WriteLine("Old People class instance {0},\nNew People class instance {1}",
                     people1.ToString(), people2.ToString());
                 break;
             case UserControl.Exercise5:
                 Console.WriteLine("Solve of {0}", UserControl.Exercise5);
                 Exercise5 exercise5 = new Exercise5();
                 exercise5.Show();
                 foreach (int age in people.Ages)
                 {
                     Console.WriteLine(age);
                 }
                 break;
             case UserControl.Exit: isExit = true; break;
             default: Instruction(); break;
         }
     }
 }