Advertisement
Guest User

Untitled

a guest
Feb 19th, 2018
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.87 KB | None | 0 0
  1.  
  2. public class Sonde {
  3. public static long ms = System.currentTimeMillis();
  4. public static double s;
  5. public static int m;
  6. public static int h;
  7. public static void autonomie () {
  8. if(ms+1000 <= System.currentTimeMillis())
  9. {
  10. s = s+ ((double)System.currentTimeMillis()-((double)ms))/1000;
  11. ms = System.currentTimeMillis();
  12. }
  13. if (s >= 60) {
  14. m = m+1;
  15. s = 0;
  16. if (m ==60) {
  17. h = h+1;
  18. m = 0;
  19. }
  20. System.out.println("Le temps d'autonomie est de"+ h+"heure"+m+"minute"+(int)s+"seconde");
  21. }
  22. }
  23. public void setSeconde (int s) {
  24. s = 0;
  25. }
  26. public void setMinute (int m) {
  27. m = 0;
  28. }
  29. public void setHeure (int h) {
  30. h = 0;
  31. }
  32. public int getSeconde() {
  33. return (int)s;
  34. }
  35. public int getMinute() {
  36. return m;
  37. }
  38. public int getHeure() {
  39. return h;
  40. }
  41.  
  42.  
  43. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement