Пример #1
0
 public static void JsonDeserialization(Practiser practiser, string path)
 {
     using (Stream stream = new FileStream(path, FileMode.OpenOrCreate))
     {
         // Deserialization from JSON
         DataContractJsonSerializer deserializer = new DataContractJsonSerializer(typeof(Practiser));
         Practiser obj = (Practiser)deserializer.ReadObject(stream);
         Console.Write("Object is deserialized");
     }
 }
Пример #2
0
 public static void JsonSerialization(Practiser practiser, string path)
 {
     using (Stream stream = new FileStream(path, FileMode.Create))
     {
         DataContractJsonSerializer ser = new DataContractJsonSerializer(typeof(Practiser));
         ser.WriteObject(stream, practiser);
         stream.Position = 0;
         StreamReader streamReader = new StreamReader(stream);
         Console.WriteLine(streamReader.ReadToEnd());
         stream.Position = 0;
         Practiser result = (Practiser)ser.ReadObject(stream);
     }
 }
Пример #3
0
     public SchoolWorkerStaff(Practiser practiser)
     {
         schoolWorkerStaff.Add(new SchoolWorker("Ehor", "Muronyik", "male", 27, "Secondary Education",
                                                "librarian", 10000));
         schoolWorkerStaff.Add(new SchoolWorker("Vadim", "Masiyk", "male", 27, "Secondary Education",
                                                "librarian", 10000));
         foreach (Human human in schoolWorkerStaff)
         {
             practiser.PracticeEvent += (f, fargs) => { human.Training(f, fargs); }
         }
         ;
     }
 }
Пример #4
0
 public TeacherStaff(Practiser practiser)
 {
     teacherStaff[0] = new Teacher("Danya", "Karpenko", "female", 56, "Secondary Education", "teacher", 20000,
                                   "higher", "mathematic");
     teacherStaff[1] = new Teacher("Lena", "Karpenko", "female", 56, "Secondary Education", "teacher", 20000,
                                   "higher", "mathematic");
     practiser.PracticeEvent += delegate(Practiser f, PracticEventArgs fargs)
     {
         for (int i = 0; i < HUMAN_AMOUNT; i++)
         {
             teacherStaff[i].Training(f, fargs);
         }
     };
 }
Пример #5
0
        static void Main(string[] args)
        {
            Practiser         practiser1   = new Practiser("Nadinka", 19, "female");
            Practiser         practiser2   = new Practiser("Yehor", 18, "male");
            TeacherStaff      teacherStaff = new  TeacherStaff(practiser1);
            SchoolWorkerStaff schoolWorker = new SchoolWorkerStaff(practiser2);

            practiser1.Practice();
            practiser2.Practice();
            Student [] students = new Student[5];
            students[0] = new Student("Olya", "Resop", "female", 14, "I I/M", 8);
            students[1] = new Student("Kolya", "Resop", "female", 14, "I I/M", 12);
            students[2] = new Student("Nadia", "Resop", "female", 14, "I I/M", 2);
            students[3] = new Student("Yehor", "Resop", "female", 14, "I I/M", 1);
            Console.WriteLine("\nStudent ration: \n");
            students[0].Ration();
            Array.Sort(students);


            FoodCollection <string> foodCollection = new   FoodCollection <string>();

            foodCollection.Add("lobster");
            foodCollection.Add("varenuki");
            foodCollection.Add("fish");
            foodCollection.Remove(0);

            foodCollection.Menu();
            Console.WriteLine(foodCollection["fish"]);
            foreach (string s in foodCollection)
            {
                Console.WriteLine("Value: {0}", s);
            }
            IEnumerator <string> iEnumeratorOfString = foodCollection.GetEnumerator();

            while (iEnumeratorOfString.MoveNext())
            {
                Console.WriteLine(iEnumeratorOfString.Current);
            }

            Serialization.XmlSerialization(students);
            Serialization.XmlDeserialization(students);
            Serialization.JsonSerialization(practiser1, "data.json");
            Serialization.JsonDeserialization(practiser1, "data.json");
        }
Пример #6
0
 public override void Training(Practiser f, PracticEventArgs fargs)
 {
     Console.WriteLine("Student can not train ");
 }
Пример #7
0
 abstract public void Training(Practiser f, PracticEventArgs fargs);