Exercises in this lecture   previous -- Keyboard shortcut: 'p'  next -- Keyboard shortcut: 'n'  Go to the notes, in which this exercise belongs -- Keyboard shortcut: 'u'   Alphabetic index   Course home      

Exercise 5.14
An interval overlap operation


Add an operation that finds the overlap between two intervals. Your starting point should be the class Interval. You can in this exercise ignore the operator overloadings in Interval.

Please analyze the possible overlappings between two intervals. There are several cases that need consideration. The fact that Interval is oriented may turn out to be a complicating factor in the solution. It may also complicate the matters that the given Interval type cannot be used to construct an empty interval. You may need to change that. As a consequence of these observations you may consider to work with non-oriented intervals in this exercise.

Which kind of operation will you chose for the overlapping operation in C# (Method, Property, Indexer)?

Before you program the operation in C# you should design the signature of the operation.

Program the operation in C#, and test your solution in an Interval client program. You may chose to extend the Interval client program from the teaching material.