Package io.bhagat.math
Class Interval
- java.lang.Object
-
- io.bhagat.math.Interval
-
public class Interval extends java.lang.ObjectA class for an interval of numbers- Author:
- Bhagat
-
-
Field Summary
Fields Modifier and Type Field Description private doublelowerBoundthe lower boundprivate booleanopenwhether it is open or notprivate doubleupperBoundthe upper bound
-
Constructor Summary
Constructors Constructor Description Interval(double lowerBound, double upperBound)creates an interval with a lower and upper bound (defaults open to false)Interval(double lowerBound, double upperBound, boolean open)creates an interval with a lower and upper bound and whether it is open or not
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description doublegetLowerBound()doublegetUpperBound()booleaninInterval(double x)checks if a number is inside this intervalbooleanisOpen()doublemidpoint()doublerange()voidsetLowerBound(double lowerBound)voidsetOpen(boolean open)voidsetUpperBound(double upperBound)
-
-
-
Constructor Detail
-
Interval
public Interval(double lowerBound, double upperBound, boolean open)creates an interval with a lower and upper bound and whether it is open or not- Parameters:
lowerBound- the lower boundupperBound- the upper boundopen- whether it is open or not
-
Interval
public Interval(double lowerBound, double upperBound)creates an interval with a lower and upper bound (defaults open to false)- Parameters:
lowerBound- the lower boundupperBound- the upper bound
-
-
Method Detail
-
inInterval
public boolean inInterval(double x)
checks if a number is inside this interval- Parameters:
x- the number- Returns:
- whether or not the number is inside the interval
-
range
public double range()
- Returns:
- the range of the interval
-
midpoint
public double midpoint()
- Returns:
- the midpoint of the interval
-
getLowerBound
public double getLowerBound()
- Returns:
- the lowerBound
-
setLowerBound
public void setLowerBound(double lowerBound)
- Parameters:
lowerBound- the lowerBound to set
-
getUpperBound
public double getUpperBound()
- Returns:
- the upperBound
-
setUpperBound
public void setUpperBound(double upperBound)
- Parameters:
upperBound- the upperBound to set
-
isOpen
public boolean isOpen()
- Returns:
- the open
-
setOpen
public void setOpen(boolean open)
- Parameters:
open- the open to set
-
-