Advertisement
Dr_U

thisTest

Oct 14th, 2020
121
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.00 KB | None | 0 0
  1.  
  2. /**
  3.  * Write a description of class ThisTest here.
  4.  *
  5.  * @author (your name)
  6.  * @version (a version number or a date)
  7.  */
  8. public class ThisTest
  9. {
  10.    
  11.     public static void ThisTest()
  12.     {
  13.        SimpleTime time= new SimpleTime(15,30,19);
  14.        System.out.println(time.buildString());
  15.     }//end main
  16. }// end class
  17.  
  18. class SimpleTime
  19. {
  20.     private int hour;//0-23
  21.     private int minute;//0-59
  22.     private int second;//0-59
  23.    
  24.     public SimpleTime(int hour,int minute, int second )
  25.     {
  26.         this.hour = hour ;
  27.         this.minute = minute;
  28.         this.second = second;
  29.     }
  30.    
  31.     public String buildString()
  32.     {
  33.        return String.format( "%24s: %s\n%24s: %s",
  34.        "This.toUniversalString()",this.toUniversalString(),
  35.        "toUniversalString()",toUniversalString() );
  36.     }
  37.     // end method buildString
  38.    
  39.     public String toUniversalString()
  40.     {
  41.         return String.format("%02d:%02d:%02d",
  42.         this.hour,this.minute,this.second);
  43.     }
  44. }
  45.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement