fork download
  1. /* package whatever; // don't place package name! */
  2.  
  3. import java.util.*;
  4. import java.lang.*;
  5. import java.io.*;
  6.  
  7. class Time{
  8. private int clock, min, cook;
  9.  
  10. Time(int clock, int min, int cook){
  11. this.clock = clock;
  12. this.min = min;
  13. this.cook = cook;
  14. }
  15.  
  16. public void CookTimeCheck() { //요리 시간 계산
  17. for(; cook >= 60; cook -= 60) //요리 시간이 1시간 이상인 경우
  18. ClockTimeCheck(); //시 단위만 증가
  19.  
  20. if(cook > 0) //그 외의 경우 분 단위만 증가
  21. MinTimeCheck();
  22. }
  23.  
  24. private void ClockTimeCheck() { //시 단위 증가
  25. if((clock += 1) > 23)
  26. clock = 0;
  27. }
  28.  
  29. private void MinTimeCheck() { //분 단위 증가
  30. if((min += cook) > 59) {
  31. min -= 60;
  32. ClockTimeCheck();
  33. }
  34. }
  35.  
  36. public int getClock() {
  37. return clock;
  38. }
  39.  
  40. public int getMin() {
  41. return min;
  42. }
  43. }
  44.  
  45. /* Name of the class has to be "Main" only if the class is public. */
  46. class Ideone
  47. {
  48. public static void main (String[] args) throws java.lang.Exception
  49. {
  50. Scanner sc = new Scanner(System.in);
  51. Time t = new Time(sc.nextInt(), sc.nextInt(), sc.nextInt());
  52. t.CookTimeCheck();
  53. System.out.println(t.getClock() + " " + t.getMin());
  54. sc.close();
  55. }
  56. }
Success #stdin #stdout 0.17s 57276KB
stdin
23 48
25
stdout
0 13