package Dating;

//~--- JDK imports ------------------------------------------------------------

import java.awt.*;
import java.awt.event.*;

import javax.swing.*;

public class Time {
    private int hours = 0;
    private int minutes = 0;
    private int seconds = 0;

    public Time() {}

    public Time(int hours, int minutes, int seconds) {
        this.add(hours, minutes, seconds);


        /*this.hours   = hours;
        this.minutes = minutes;
        this.seconds = seconds;*/
    }

    public void add(Time t) {
        add(t.getHours(), t.getMinutes(), t.getSeconds());
    }

    public void add(int hours, int minutes, int seconds) {
        this.seconds = this.seconds + seconds;
        this.minutes = this.minutes + minutes;
        this.hours = this.hours + hours;

        for (;;) {

            if (this.seconds >= 60) {
                this.minutes++;
                this.seconds = this.seconds - 60;
            } else {
                break;
            }
        }

        for (;;) {

            if (this.minutes >= 60) {
                this.hours++;
                this.minutes = this.minutes - 60;
            } else {
                break;
            }
        }
    }

    public String asString() {
        String returnS;

        if (hours < 10) {
            returnS = "0" + hours;
        } else {
            returnS = "" + hours;
        }

        if (minutes < 10) {
            returnS = returnS + ":0" + minutes;
        } else {
            returnS = returnS + ":" + minutes;
        }

        if (seconds < 10) {
            returnS = returnS + ":0" + seconds;
        } else {
            returnS = returnS + ":" + seconds;
        }

        return returnS;
    }

    public int getHours() {
        return hours;
    }

    public int getMinutes() {
        return minutes;
    }

    public int getSeconds() {
        return seconds;
    }

    public void setHours(int hours) {
        this.hours = hours;
    }

    public void setMinutes(int minutes) {
        this.minutes = minutes;
    }

    public void setSeconds(int seconds) {
        this.seconds = seconds;
    }
}


//~ Formatted by Jindent --- http://www.jindent.com
