All pastes #2075855 Raw Edit

Something

public text v1 · immutable
#2075855 ·published 2011-06-07 00:32 UTC
rendered paste body
/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Time;

public class Time {
int hours, minutes;

Time(int hr, int min){
 this.hours = hr + (min/60);
 this.minutes = min % 60;
  }

Time(double hrmin){
 this.hours = (int)hrmin;
 this.minutes = (int)(hrmin % 1) * 60;
}

@Override public String toString(){
return String.format("%d:%02d", hours, minutes);
}

    public static void main(String[] args) {
        
        
        System.out.println(new Time(9,30));
        System.out.println(new Time(21,30));
        System.out.println(new Time(10,93));
        System.out.println(new Time(9.5));
        System.out.println(new Time(21.5));
        System.out.println(new Time(0));
        System.out.println(new Time(1,1));
        
        }
}