|
|
| Function.java |
import java.util.*;
public class Function {
/**
* Evaluate the function at the given value of x.
*
* @x argument of the function.
* @return the value of the function at x.
*/
public double evaluate(double x) {
return Math.sin(x);
}
}
|
![]() | The real-valued function f(x) we like to graph is
best wrapped into a class. This allows us later to change
the function without modifying the class that draws graphs.
|
![]() | Using inheritance, it is even possible to use other
functions without modifying Function. This is handled
later in CS2.
|
|
| Copyright © 2001, 2002 Andreas Borchert, converted to HTML on February 11, 2002 |