-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathPerson.cs
More file actions
29 lines (24 loc) · 784 Bytes
/
Copy pathPerson.cs
File metadata and controls
29 lines (24 loc) · 784 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
namespace CsCodeExample;
public class Address
{
public string City { get; set; }
public string Street { get; set; }
public int Number { get; set; }
}
public abstract class Human // keyword: abstract, can not be initialised, only inhereted
{
public DateTime BirthDate { get; set; }
}
public class Person : Human
{
public string FirstName { get; set; }
public string LastName { get; set; }
public Sex PersonSex { get; set; }
public Address HomeAddress { get; set; } // Composition
public int Age { get { return DateTime.Now.Year - BirthDate.Year; } }
public string DisplayName { get { return FirstName + " " + LastName; } }
public override string ToString()
{
return String.Format("{0} {1}", FirstName, LastName);
}
}