Prise2.java
1.8 KB
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
65
66
67
68
69
70
71
72
73
74
package com.example.martin.projetv5;
/**
* Created by martin on 20/02/2017.
*/
public class Prise2 implements Comparable<Prise2>{
Integer idP;
Integer idMedoc;
String effectuee;
String heurePrescrite;
public Prise2(Integer pId, Integer pIdMedoc, String pEffectuee, String pHeure) {
idP = pId;
idMedoc = pIdMedoc;
effectuee = pEffectuee;
heurePrescrite = pHeure;
}
@Override
public int compareTo(Prise2 p) {
String[] s1 = this.getHeure().split("h");
String[] s2 = p.getHeure().split("h");
int cmp;
if (Integer.parseInt(s1[0]) > Integer.parseInt(s2[0]))
cmp = +1;
else if (Integer.parseInt(s1[0]) < Integer.parseInt(s2[0]))
cmp = -1;
else{
if (Integer.parseInt(s1[1]) > Integer.parseInt(s2[1]))
cmp = +1;
else if (Integer.parseInt(s1[1]) < Integer.parseInt(s2[1]))
cmp = -1;
else
cmp = 0;
}
return cmp;
/*
if(s1[0].compareTo(s2[0]) == 0){;
return s1[1].compareTo(s2[1]);
}
else return s1[0].compareTo(s2[0]);
*/
}
public void setId(Integer pId){
idP = pId;
}
public void setIdMedoc(Integer pIdM){
idMedoc = pIdM;
}
public void setEffectuee(String pEffectuee){
effectuee = pEffectuee;
}
public void setHeure(String pHeure){
heurePrescrite = pHeure;
}
public Integer getId(){
return idP;
}
public Integer getIdMedoc(){
return idMedoc;
}
public String getEffectuee(){
return effectuee;
}
public String getHeure(){
return heurePrescrite;
}
}