public class TimeMoment implements Comparable<TimeMoment> {
  private double t;
  private int c;

  public TimeMoment(double t, int c) {
    this.t = t;
    this.c = c;
  }

  public int compareTo(TimeMoment other) {
    if ((Double.compare(this.t, other.t) < 0) || (Double.compare(this.t, other.t) == 0 && this.c < other.c))
      return -1;
    if ((Double.compare(this.t, other.t) > 0) || (Double.compare(this.t, other.t) == 0 && this.c > other.c))
      return 1;
    return 0;
  }

  public TimeMoment advance(TimeMoment other) {
    if (other.t == 0)
      return new TimeMoment(this.t, this.c + other.c);
    return new TimeMoment(this.t + other.t, 0); 
  }
}
