Advertisement
Guest User

Untitled

a guest
Mar 25th, 2017
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.38 KB | None | 0 0
  1. package SO1;
  2.  
  3. public class Process implements Comparable<Process>, Cloneable
  4. {
  5. private int _time;
  6. final int ID;
  7. private int _wholeProcessTime;
  8. private int _addTime =0;
  9. private int _endTime =0;
  10. private boolean _done = false;
  11.  
  12. public Process(int t, int id)
  13. {
  14. _time = t;
  15. _wholeProcessTime = t;
  16. ID = id;
  17. }
  18.  
  19. public void executePart()
  20. {
  21. _time--;
  22. }
  23.  
  24. public void set_endTime(int t)
  25. {
  26. _endTime = t;
  27. }
  28.  
  29. public void set_addTime(int t)
  30. {
  31. _addTime = t;
  32. }
  33.  
  34. @Override
  35. public Object clone() throws CloneNotSupportedException {
  36. return super.clone();
  37. }
  38.  
  39. public int compareTo(Process process)
  40. {
  41. if(_time>process._time)
  42. return 1;
  43. else if(_time==process._time)
  44. return 0;
  45. else
  46. return -1;
  47. }
  48.  
  49. @Override
  50. public String toString()
  51. {
  52. return "id :" + ID + " Time: " + _wholeProcessTime + " wait :" + getWaitingTime(); //" Add Time " + _addTime +
  53. }
  54.  
  55. public boolean idDone()
  56. {
  57. return _done;
  58. }
  59.  
  60. public void markAsDone()
  61. {
  62. _done = true;
  63. }
  64.  
  65. public int getWaitingTime()
  66. {
  67. return _endTime-_addTime-_wholeProcessTime;
  68. }
  69.  
  70.  
  71. public int getTime()
  72. {
  73. return _time;
  74. }
  75. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement