% Play with the Interval class

p= Interval(3,7);  % p references a newly created Interval object
r= Interval(4,9);
s= Interval(0,1);

% Demonstrate overlap method
a= p.overlap(r)
b= p.overlap(s)

pause
% Experiment with random intervals
fprintf('\nGenerate random intervals and check if there is overlap\n')
for k=1:5
    fprintf('Trial %d\n', k)
    a= Interval(3,3+rand*5);
    b= Interval(6,6+rand*3);
    disp(a)
    disp(b)
    c= a.overlap(b);
    if ~isempty(c)
        fprintf('Overlap is ')
        disp(c)
    else
        disp('No overlap')
    end
    pause
end
