package leto_cvic03; public class Interval { public final double low; public final double high; public Interval(double l, double h) { low=l; high=h; } public Interval(){ low=Double.POSITIVE_INFINITY; high=Double.NEGATIVE_INFINITY; } public boolean isEmpty(){ return low > high; } public String toString(){ if(isEmpty())return "interval is empty"; return "Interval ["+low+", "+high+"]"; } public static Interval prunik(Interval a, Interval b) { if (a==null || b==null ) return new Interval(); return new Interval( Math.max(a.low, b.low), // maximum low Math.min(a.high, b.high) // minimum high ); } public static Interval prunik(Interval[] p) { if (p==null || p.length==0 || p[0]==null) return new Interval(); Interval res= new Interval(p[0].low, p[0].high); for (int i = 1; i < p.length; i++) { res=Interval.prunik(res, p[i]); } return res; } public static void main(String[] args){ Interval it1=new Interval(); System.out.println(it1.toString()); } } _________________________________ cvic 03C XInterval _________________________________ package leto_cvic03c; import leto_cvic03.*; public class XInterval extends Interval { public XInterval(double l, double h) { super (l,h); } public XInterval() { super (); } public String toString(){ return "X"+super.toString(); } public double getLength(){ return high-low; } //pretizeni public XInterval[] union(XInterval a , XInterval b){ } public XInterval[] union(XInterval[] pole){} /* public static void main(String[] args){ Interval it1=new Interval(20,30); System.out.println(it1.toString()); }*/ }