Exemple #1
0
        static void Main(string[] args)
        {
            Student[] students = new Student[5];
            students[0] = new Student();

            //Student students = new Student();
            //students[0] = student;
            students[0].Name = "Pekka";
            students[0].Age = 15;
            students[0].Class = 9;
            students[0].Absent = true;
            students[1].Name = "Anna";
            students[1].Age = 15;
            students[1].Class = 9;
            //students[1].Absent = true;
            students[2].Name = "Miia";
            students[2].Age = 15;
            students[2].Class = 9;
            //students[2].Absent = true;
            students[3].Name = "Kalle";
            students[3].Age = 15;
            students[3].Class = 9;
            students[3].Absent = true;
            students[4].Name = "Antti";
            students[4].Age = 15;
            students[4].Class = 9;
            //students[4].Absent = true;

            // students[0] = student;
            foreach (Student PrintData in students) ;
            //for (Student students = 0; i < students; i++) Console.WriteLine(students[i]);
            Console.ReadLine();
        }
Exemple #2
0
        static void Main(string[] args)
        {
            Student[] student = new Student[5];

            student[0].Name = "Timo";
            student[0].Motivation = 9001;

            student[1].Name = "Tero";
            student[1].Motivation = 2;

            student[2].Name = "Jorma";
            student[2].Motivation = 71;

            student[3].Name = "Kalle";
            student[3].Motivation = 54;

            student[4].Name = "Matti";
            student[4].Motivation = -2000;

            for(int i = 0; i<5 ; i++)
            {
                Console.WriteLine(student[i].Name + " motivaatio: " + student[i].Motivation);

            }

            Console.ReadLine();

        }
Exemple #3
0
        static void Main(string[] args)
        {
            //create an array
            Student[] students = new Student[4];

            //save students in array
            for (int i = 0; i < students.Length; i++)
            {
                students[i] = new Student();
            }

            //change the information of the student in the first index
            students[0].Name = "Saara Virtanen";
            students[0].Credits = 35;
            students[0].AddCredits();
            students[0].Age = 21;
            students[0].StudentNo = "K1698";
            students[0].Field = "ICT";
            students[0].HaveABeer();

            //print students
            for (int i = 0; i < students.Length; i++)
            {
                students[i].PrintData();
            }

            //using parametric constructor
            Student student2 = new Student("Pena", 19, "K1111", true);
            student2.PrintData();
        }
Exemple #4
0
        static void Main(string[] args)
        {
            Student[] student = new Student[6];

            for (int i = 0; i <= 5; i++)
            {
                student[i] = new Student();
            }

            student[1].Name = "Kimmo Oinonen";
            student[1].ID = "K1744";
            student[1].Group = "TTV15S3";
            student[1].Age = 21;
            student[1].PrintData();
            
            student[2].Name = "Opiskelija 2";
            student[2].ID = "K1234";
            student[2].Group = "TTV15S3";
            student[2].Age = 19;
            student[2].PrintData();

            student[3].Name = "Opiskelija 3";
            student[3].ID = "K2345";
            student[3].Group = "TTV15S3";
            student[3].Age = 20;
            student[3].PrintData();

            student[4].Name = "Opiskelija 4";
            student[4].ID = "K3456";
            student[4].Group = "TTV15S3";
            student[4].Age = 22;
            student[4].PrintData();

            student[5].Name = "Opiskelija 5";
            student[5].ID = "K4567";
            student[5].Group = "TTV15S3";
            student[5].Age = 23;
            student[5].PrintData();

            Console.ReadLine();
        }
Exemple #5
0
        static void Main(string[] args)
        {
            // create 5 students
            Student[] students = new Student[5];
            students[0] = new Student();
            students[0].Name = "Jussi";
            students[0].DoHomework();
            students[1] = new Student();
            students[1].Name = "Spede";
            students[1].Tired = false;
            students[2] = new Student();
            students[2].Name = "Marko";
            students[2].Age = 40;
            students[3] = new Student();
            students[3].Name = "Sepi";
            students[4] = new Student();
            students[4].Name = "Johannes";

            // print everyone's attributes
            foreach (Student student in students)
            {
                student.PrintData();
            }
        }