Guest User

Untitled

a guest
Oct 14th, 2020
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.93 KB | None | 0 0
  1. /**
  2.  * Write a description of class thistest here.
  3.  *
  4.  * @author (Muhammad Bagus Istighfar)
  5.  * @version (14.10.20)
  6.  */
  7. public class thistest
  8. {
  9.     public static void main (String[] args)
  10.     {
  11.         SimpleTime time = new SimpleTime(15,30,19);
  12.         System.out.println(time.buildString());
  13.     }
  14. }
  15.  
  16. class SimpleTime
  17. {
  18.     private int hours;
  19.     private int minute;
  20.     private int second;
  21.    
  22.     public SimpleTime( int hours, int minute, int second)
  23.     {
  24.         this.hours = hours;
  25.         this.minute=minute;
  26.         this.second= second;
  27.     }
  28.     public String buildString()
  29.     {
  30.         return String.format ("%24s: %s\n%24s: %s",
  31.         "this.toUniversalString()", this.toUniversalString(),"toUniversalString()",
  32.         toUniversalString());
  33.     }
  34.     public String toUniversalString()
  35.     {
  36.         return String.format("%02d:%02d:%02d",this.hours,
  37.         this.minute, this.second);
  38.     }
  39.    
  40. }
Advertisement
Add Comment
Please, Sign In to add comment