/****************************************************************************
                               Arup Guha
                                  CS 302
                                  3/1/99
                           My first class : Time

                      Edited in BHCSI class 7/19/06.

*****************************************************************************/

import java.util.*;

public class Time2 {

    private int hours;  // number of hours in the time object.
    private int minutes; // number of minutes in the time object.

    // A constructor that takes in the hours and minutes respectively and
    // creates a time object accordingly.
    public Time2(int h, int m) {
		hours = h;
		minutes = m;
    }

    // A constructor that just takes in a single integer representing the
    // total number of minutes for an amount of time.
    public Time2(int m) {
		hours = m/60;
		minutes = m%60;
    }

    // Default constructor, sets the time object to 0 hours and minutes.
    public Time2() {
		hours = 0;
		minutes = 0;
    }

    public int getHours() {
		return hours;
    }
    
    public int getMinutes() {
		return minutes;
    }

    public void setHours(int h) {
		hours = h;
    }
    
    public void setMinutes(int m) {
		minutes = m;
    }

    // Returns the number of minutes a Time object is.
    int totalminutes() {
		return 60*hours + minutes;
    }

    // Returns true if the argument to the method is equal in Time to the
    // Time object the method is called on.
    public boolean equals2(Time2 time2) {
	
		if (this.totalminutes() == time2.totalminutes())
		    return true;
		else
		    return false;
    }

    // Returns true if the argument to the method is longer in Time to the
    // Time object the method is called on.
    public boolean greaterthan(Time2 time2) {
	
		if (totalminutes() > time2.totalminutes())
		    return true;
		else
		    return false;
    }

    // Adds the Time of the argument with the object the method is called on
    // together and returns their sum as a Time object.
    public Time2 addtime(Time2 time2) {
		int min = totalminutes() + time2.totalminutes();
		Time2 temp = new Time2(min);
		return temp;
    }

    // Returns the difference in Time between the argument and the object
    // the method is called on. A Time object is returned.
    public Time2 difference(Time2 time2) {
		int min = Math.abs(totalminutes() - time2.totalminutes());
		Time2 temp = new Time2(min);
		return temp;
    }
    
    public void doubleit() {
    	int myminutes = totalminutes();
    	myminutes = 2*myminutes;
    	hours = myminutes/60; // return new Time(myminutes);
    	minutes = myminutes%60;
    }
    
    public Time2 doubleit2() {
    	int myminutes = totalminutes();
    	myminutes = 2*myminutes;
    	return new Time2(myminutes);
    }
    
    public int compareTo(Time2 t) {
    	
    	if (this.greaterthan(t))
    		return 1;
    	else if (this.equals(t))
    		return 0;
    	else
    		return -1;
    		
    	// return this.totalminutes() - t.totalminutes();
    }
    
    public String toString() {
		return (hours + " hours and " + minutes + " minutes");
    }
    
    public static void main(String args[]) {

		Scanner stdin = new Scanner(System.in);

		System.out.println("Enter how long it took to bake your dinner");
		System.out.println("First enter hours followed by minutes on the next line.");
		int hours_bake = stdin.nextInt();
		int minutes_bake = stdin.nextInt();

		System.out.println("Enter how long it took to nuke your dinner");
		System.out.println("First enter hours followed by hours on the next line.");
		int hours_nuke = stdin.nextInt();
		int minutes_nuke = stdin.nextInt();

		Time2 bake = new Time2(hours_bake, minutes_bake);
		Time2 nuke = new Time2(hours_nuke, minutes_nuke);
		bake = bake.doubleit2();

		if (bake.equals(nuke)) {
		    	System.out.println("Baking and Microwaving this food take the same amount of time.");
		}
		else if (bake.greaterthan(nuke)) {
	 	   	Time2 temp = bake.difference(nuke);
	 	   	System.out.println("Microwaving will save you "+temp+" amount of time.");
		}
		else {
		    	Time2 temp = nuke.difference(bake);
	  		System.out.println("You are cooking some really weird stuff.");
	   		System.out.println("Baking will save you "+temp+" amount of time.");
		}
		
    }
    
}

