コード例 #1
0
ファイル: Grade calculator.cs プロジェクト: PURICH636/Testing
        static void Main(string[] args)
        {
            Student std = new Student();

            Console.Write("Enter your score: ");
            double score = double.Parse(Console.ReadLine());
            char chGrade = std.ComputeGrade(score);
            Console.WriteLine("Your grade is {0}", chGrade);

            Console.ReadKey();
        }
コード例 #2
0
ファイル: Program.cs プロジェクト: PolyakovSergey95/OOP
 static void Main(string[] args)
 {
     Student S1 = new Student();
     Console.WriteLine(S1.ToShortString());
     S1.PersonVal = new Person("Sergey", "Polyakov", new DateTime(1995, 4, 9));
     S1.StudentEducation = Education.Specialist;
     S1.GroupNumberVal = 232;
     S1.ExamsVal = new Exam[4];
     S1.TestsVal = new System.Collections.ArrayList();
     Console.WriteLine(S1.ToString());
     Exam[] buf = new Exam[] { new Exam("Programming", 5, new DateTime(2015, 12, 01)), new Exam("Economics", 5, new DateTime(2015, 12, 11)),
     new Exam("Math", 5, new DateTime(2015, 12, 14)), new Exam("Foreign language", 4, new DateTime(2015, 12, 20))};
     S1.AddExams(buf);
     Console.WriteLine(S1.ToString());
     Person p1 = new Person("Name", "SName", new DateTime(1998, 1, 1));
     Person p2 = new Person("Name", "SName", new DateTime(1998, 1, 1));
     Console.WriteLine(p1==p2);
     Console.WriteLine(p1.Equals(p2));
     Console.WriteLine(p1.GetHashCode().ToString()+" "+p2.GetHashCode().ToString());
     Student S2 = new Student("Ivan", "Ivanov", new DateTime(1994, 4, 5), Education.Bachelor, 432);
     S2.AddExams(new Exam[] {new Exam("Math", 5, new DateTime(2015,4,30)), new Exam("Biology", 4 ,new DateTime(2015,4,25))});
     S2.AddTests(new Test[] { new Test("Philosophy", true, new DateTime(2015, 4, 15)), new Test("Social", true, new DateTime(2015, 4, 10)) });
     Console.WriteLine(S2.ToString());
     Student S21 = (Student)S2.DeepCopy();
     S2.NameVal = "Petr";
     S2.SecondNameVal = "Petrov";
     Console.WriteLine(S2.ToString());
     Console.WriteLine(S21.ToString());
     S2.GroupNumberVal = 1000;
     foreach (Exam Ex in S2.ExamsVal)
     {
         if (Ex!=null)
             Console.WriteLine(Ex.ToString());
     }
     foreach (Test Ts in S2.TestsVal)
     {
         if (Ts != null)
             Console.WriteLine(Ts);
     }
     foreach (Exam Ex in S2.ExamsVal)
     {
         if ((Ex != null) && (Ex.Mark>3))
             Console.WriteLine(Ex.ToString());
     }
 }
コード例 #3
0
        static void Main(string[] args)
        {
            Person[] malta; // criar um instancia q identifica um array de Person
            malta = new Person[10]; // identifica q malta é um array de 10

            malta[0] = new Person("Zé", new DateTime(2005, 1, 1),true);
            malta[1] = new Student("Manel", new DateTime(2006, 1, 1), 10);
            malta[2] = new Person("Xico", new DateTime(2002, 1, 1), false);
            malta[3] = new Teacher("Mário", new DateTime(2002, 1, 1), Teacher.Categoria.assistente);

            foreach (Person elemento in malta)
            {
                if (elemento != null)
                    Console.WriteLine("{0} Idade: {1}", elemento, elemento.Age);
            }


             string fich;
            Console.Write("Indique ficheiro: ");

            fich = Console.ReadLine();

            Person.SavePersons(malta, fich);

            var malta1 = Person.ReadFilePersons(fich);
            Console.WriteLine("Leu");
            foreach (Person elemento in malta1)
            {
                Console.WriteLine(elemento);
                Console.WriteLine();
            }


        }
コード例 #4
0
        static void Main5(string[] args)
        {
            Person[] malta; // criar um instancia q identifica um array de Person
            malta = new Person[10]; // identifica q malta é um array de 10




            /*int max = 3; // máx pessoas a ler
            
            for (int pointer = 0; pointer < max; ++pointer)
            {

                malta[pointer] = ObtemNome();
            }*/

            int max = ReadFilePersons(malta, "Pessoas.txt");

            for (int pointer = 0; pointer < max; ++pointer)
            {

                Console.WriteLine(malta[pointer].ToString()); 
            }
            malta[3] = new Student("Zé", new DateTime(2005, 1, 1), 10);

            foreach (Person elemento in malta)
            {
                if (elemento != null)
                    Console.WriteLine("{0} Idade: {1}", elemento, elemento.Age);
            }

            int i;
            string linha1;
            Console.Write("Introduza número:");
            
            linha1 = Console.ReadLine();
            i = int.Parse(linha1);
            //Console.WriteLine(malta[i].ToString()); 

            
            Student s = malta [i] as Student;
            if (s != null)
                Console.WriteLine("nr_aluno {0} ", s.nr_aluno);
            else 
                Console.WriteLine("Não é estudante  {0} ", malta [i]); 
            //Console.WriteLine("Fim");


        }
コード例 #5
0
ファイル: Student.cs プロジェクト: PolyakovSergey95/OOP
 public override object DeepCopy()
 {
     Person p = (Person)base.DeepCopy();
     Student s = new Student(p.NameVal, p.SecondNameVal, p.Date, StudentEducation, GroupNumber);
     s.TestsVal = TestsVal;
     s.ExamsVal = ExamsVal;
     return s;
 }