Please use java to write a program Graphing Create a class e

Please use java to write a program

Graphing Create a class expr.ChartData with a 0 argument constructor and following methods

public void setExpression( Expression a )

public Expression getExpression( )

public void setXRange( double xMin, double xMax )

public double getXMin( )

public double getXMax( )

public void setYRange( double yMin, double yMax ) p

ublic double getYMin( )

public double getYMax( )

The following class invariants should be respected

getExpression() != null

Double.NEGATIVE_INFINITY < getXMin( )

getXMin( ) < getXMax( )

getXMax( ) < Double.POSITIVE_INFINITY

Double.NEGATIVE_INFINITY < getYMin( )

getYMin( ) < getYMax( )

getYMax( ) < Double.POSITIVE_INFINITY

The way you will use to ensure these invariants are respected is by using preconditions for the setter methods –i.e. we will shift responsibility from the class to its clients– and by using reasonable defaults in the constructor. These preconditions should be checked using class util.Assert, which I will supply. The class invariants can be checked by calling a private invariant method at the end of the constructor and of each mutator. The invariant method uses util.Assert to check the invariant.

Once you have implemented this class you should be able to test it with the supplied JUnit tests and run the supplied.

Bonus. You might want to extend the graphing application to support more functions and operations. To do this, you will need to modify the parser and you will need to use JavaCC to regenerate the Java classes that make up the parser.

Solution

package expr;

import java.util.Assert;

import java.beans.Expression;

Class CharData{

private Expression a;

private double xMin, xMax,yMin,yMax;

public CharData(){

xMin=0;

xMax=0;

yMin=0;

yMax=0;

a = null;

}

public void setExpression( Expression a ){

this.a = a;

}

public Expression getExpression( ){

assert null != a;

return a;

}

public void setXRange( double xMin, double xMax ){

assert Double.NEGATIVE_INFINITY < xMin;

assert Double.POSITIVE_INFINITY > xMax;

this.xMin = xMin;

this.xMax = xmax;

}

public double getXMin( ){

return xMin;

}

public double getXMax( ){

return xMax;

}

public void setYRange( double yMin, double yMax ){

assert Double.NEGATIVE_INFINITY < yMin;

assert Double.POSITIVE_INFINITY > yMax;

this.yMin = yMin;

this.yMax = ymax;

}

public double getYMin( ){

return yMin;

}

public double getYMax( ){

return yMax;

}

}

Please use java to write a program Graphing Create a class expr.ChartData with a 0 argument constructor and following methods public void setExpression( Express
Please use java to write a program Graphing Create a class expr.ChartData with a 0 argument constructor and following methods public void setExpression( Express
Please use java to write a program Graphing Create a class expr.ChartData with a 0 argument constructor and following methods public void setExpression( Express

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site