import java.util.Scanner;

//the Midterm class represents a student's midterm interval
class Midterm
{
  public int start, end;
 
  public void SetValues(int s, int t)
  {
    start = s;
    end = t;
  }
  int GetEnd()
  {
    return end;
  }
  int GetStart()
  {
    return start;
  }
}

//MidtermExample is a program that takes 2 midterms as input
//and determines if their times conflict
class MidtermExample
{
  public static void main(String [] args) throws IOException
  {
    String inputLine;
    Scanner scan = new Scanner(System.in);
    
    int s, t;
    Midterm m1 = new Midterm();
    Midterm m2 = new Midterm();
    
    //get the input--note the for loop usage
    //make sure you understand how this works 

    for(int i = 1; i <= 2; ++i)
    {
      //you type in a line, it gets stored in InputLine
      System.out.print("Type in start of midterm " + i +": ");
      s = scan.nextInt();
      System.out.print("Type in end of midterm " + i +": "); 
      t = scan.nextInt();
      if(i == 1)
      {
        m1.SetValues(s, t);
      }
      else      {
        m2.SetValues(s, t);
      }
    }
    
    //exercise: insert some code here that checks the start and end times are valid
    //Hint: the midterm will not occur from 11pm-1am...

    //now test for conflict
    if(m1.GetEnd() < m2.GetStart() || m2.GetEnd() < m1.GetStart())
    {
      System.out.println("No conflicts.");
    }
    else
    {
      System.out.println("We have a conflict.");
    }

    //exercise: rewrite the above to test the opposite, i.e. so that it prints "Have a conflict" in the if.
    //use Demorgan's law, instead of simply !(what's currently in the if)

    System.out.println("End of conflict program.");
  }
}
