Advertisement
Guest User

Untitled

a guest
Dec 13th, 2019
172
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.82 KB | None | 0 0
  1. import java.io.Serializable;
  2. import java.time.LocalDate;
  3. import java.time.Period;
  4.  
  5. /**
  6. *
  7. * @author joaop e jasonw
  8. */
  9. public abstract class Tarefa implements Serializable{
  10.  
  11. ////////////////////////////////////////////////////////////////////////////
  12. //Varíaveis e construtor
  13.  
  14. /**
  15. *Descriçao da tarefa
  16. */
  17.  
  18. protected String descricao;
  19.  
  20. /**
  21. *Responsavel da Tarefa
  22. */
  23. protected Pessoa responsavel;
  24.  
  25. /**
  26. *Data Inicio da Tarefa
  27. */
  28. protected final LocalDate dataInicio;
  29.  
  30. /**
  31. *Data fim da Tarefa
  32. */
  33. protected LocalDate dataFim;
  34.  
  35. /**
  36. *Duracao estimada em dias da tarefa
  37. */
  38. protected int durEstimada; //Número de dias
  39.  
  40. /**
  41. *Taxa de execução da tarefa
  42. */
  43. protected double taxaExecucao;
  44.  
  45. Tarefa(String novaDescricao, LocalDate novaDataInicio, int novaDurEstimada){
  46. this.descricao = novaDescricao;
  47. this.dataInicio = novaDataInicio;
  48. this.durEstimada = novaDurEstimada;
  49. this.taxaExecucao = 0.0;
  50. }
  51.  
  52. ////////////////////////////////////////////////////////////////////////////
  53. //Métodos abstratos, de @Override, getters e setters
  54.  
  55. public void setResponsavel(Pessoa novaResponsavel){ this.responsavel = novaResponsavel; }
  56. public void setDataFim(LocalDate novaDataFim){ this.dataFim = novaDataFim; }
  57. public void setTaxaExecucao(double novaTaxaExecucao){
  58. this.taxaExecucao = novaTaxaExecucao;
  59. if(this.taxaExecucao == 100.0){
  60. setDataFim(LocalDate.now());
  61. }
  62. }
  63.  
  64. /**
  65. *Metodo abstrato que deolve taxa de esforço
  66. * @return
  67. */
  68. public abstract double taxaEsforco();
  69.  
  70. public String getDescricao() { return descricao; }
  71.  
  72. public Pessoa getResponsavel() { return responsavel; }
  73.  
  74. public LocalDate getDataInicio() { return dataInicio; }
  75.  
  76. public LocalDate getDataFim() { return dataFim; }
  77.  
  78. public int getDurEstimada() { return durEstimada; }
  79.  
  80. public double getTaxaExecucao() { return taxaExecucao; }
  81.  
  82. @Override
  83. public String toString(){ return this.descricao + " (a " + this.taxaExecucao + "%)"; }
  84.  
  85. //Verifica se a tarefa está concluída
  86.  
  87. /**
  88. * Metodo que verifica se a tarefa esta concluida
  89. * @return
  90. */
  91. public int concluido(){
  92. if(this.taxaExecucao == 0.0) return -1;
  93. else if(this.dataFim == null) return 0;
  94.  
  95. LocalDate dataFimEstimada = this.dataInicio.plusDays(this.durEstimada);
  96. Period dur1 = Period.between(this.dataFim, this.dataInicio);
  97. Period dur2 = Period.between(this.dataFim, dataFimEstimada);
  98.  
  99. if((dur1.getDays()-dur2.getDays()) > 0){
  100. return 2;
  101. }else{
  102. return 1;
  103. }
  104. }
  105. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement