src/horaris/Tempo.java
author viric@mandarina
Sun, 01 Jul 2007 19:28:26 +0200
changeset 14 2f4bcc04b9e7
parent 4 f92e04d4bfe5
permissions -rw-r--r--
Removed 'loko' from Tempo.java. ??

package horaris;

public class Tempo
{
	String s;
	private int horoj;
	private int minutoj;

	public Tempo(String tempo)
	{
		fromStr(tempo);
	}

	private void fromStr(String _s)
	{
		s = _s;
		int colon = s.indexOf(':');

		horoj = Integer.parseInt(s.substring(0,colon));
		minutoj = Integer.parseInt(s.substring(colon+1));
	}

	/* 1: this later than t2
	 * 0: this equal to t2
	 * -1: this earlier than t2 */
	public int compareTo(Tempo t2)
	{
		if (horoj > t2.horoj)
			return 1;
		else if (horoj == t2.horoj && minutoj > t2.minutoj)
			return 1;
		else if (horoj == t2.horoj && minutoj == t2.minutoj)
			return 0;
		else
			return -1;
	}

	public String toString()
	{
		return s;
	}
}