Advertisement
Guest User

Untitled

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