-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPessoa.cs
59 lines (52 loc) · 1.56 KB
/
Pessoa.cs
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApp4
{
class Pessoa : IComparable
{
public string Gender { get; set; }
public string GivenName { get; set; }
public string MiddleInitial { get; set; }
public string SurName { get; set; }
public string Age { get; set; }
public Pessoa (string gender , string givenName, string middleInitial, string sunName, string age)
{
this.Gender = gender;
this.GivenName = givenName;
this.MiddleInitial = middleInitial;
this.SurName = sunName;
this.Age = age;
}
public override string ToString()
{
return Gender.PadRight(20)
+ ""
+ GivenName.PadRight(20)
+ ""
+ MiddleInitial.PadRight(20)
+ ""
+ SurName.PadRight(20)
+ ""
+ Age;
}
public int CompareTo(object obj) {
Pessoa outro = (Pessoa)obj;
int resultado = GivenName.CompareTo(outro.GivenName);
if(resultado != 0) {
return resultado;
}
else {
int resultado2 = SurName.CompareTo(outro.SurName);
if(resultado2 != 0) {
return resultado2;
}
else {
return Age.CompareTo(outro.Age);
}
}
}
}
}