-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPersonne.swift
64 lines (47 loc) · 1.29 KB
/
Personne.swift
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
60
61
62
63
64
//
// Personne.swift
// PersonneApp
//
// Created by Theodora-Augustina DRAGAN on 12/03/2019.
// Copyright © 2019 Theodora-Augustina DRAGAN. All rights reserved.
//
import Foundation
class Person : Equatable{
var firstNom : String
var lastNom: String
var dateNaiss : Date?
var agee : Int?
init(firstname : String, lastname : String){
self.firstNom = firstname
self.lastNom = lastname
self.dateNaiss = Date()
self.agee = 0
}
func lastname() -> String {
return self.lastNom
}
func firstname() -> String {
return self.firstNom
}
func fullname() -> String {
return firstname() + String(" ") + lastname()
}
func birthdate() -> Date? {
return self.dateNaiss
}
func birthdate(newDate : Date){
self.dateNaiss = newDate
}
func age()-> Int?{
return self.agee
}
static func ==(p1 : Person, p2 : Person) -> Bool {
if let tmp1 = p1.birthdate() , let tmp2 = p2.birthdate() {
return p1.firstname() == p2.firstname() && p1.lastname() == p2.lastname() && tmp1 == tmp2
}
return false
}
static func !=(p1 : Person, p2 : Person) -> Bool {
return !(p1==p2)
}
}