Introduces jpeg-recovery source-code
[lcapit-junk-code.git] / obj-array.cs
blob576d021c43413a5ba9995fdfb540a16a73f89b57
1 using System;
3 namespace ObjArray
5 class Person
7 private int age = 10;
8 private string name = "Bukowski";
10 public bool set_age(int val)
12 if (val <= 0)
13 return false;
14 age = val;
15 return true;
18 public int get_age()
20 return age;
23 public void set_name(string new_name)
25 name = new_name;
28 public string get_name()
30 return name;
34 class Program
36 static void Main(string[] args)
38 Person[] students;
39 const int nr_students = 3;
41 students = new Person[nr_students];
43 for (int i = 0; i < students.Length; i++) {
44 students[i] = new Person();
46 Console.Write("\nName: ");
47 students[i].set_name(Console.ReadLine());
49 Console.Write("Age: ");
50 int aux = Convert.ToInt32(Console.ReadLine());
51 students[i].set_age(aux);
54 for (int i = 0; i < students.Length; i++) {
55 Console.WriteLine("\nName: {0}",
56 students[i].get_name());
57 Console.WriteLine("Age: {0}",
58 students[i].get_age());