package com.example.martin.projetv5; /** * Created by martin on 20/02/2017. */ public class Prise2 implements Comparable{ 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; } }