Hi im doing this project for class and i cant get it to work. this is for my jav
ID: 3625661 • Letter: H
Question
Hi im doing this project for class and i cant get it to work. this is for my java class. i was given a equation.java file that had these codes in it* <p>CS110 Project 3 test cases</p> */?import junit.framework.TestCase;?public class EquationTest extends TestCase{ // test cases for a single equation object public void testSingleEquation() { Equation uut = new Equation( 1, 1, 1); assertEquals(-1.0, uut.slope(), Equation.THRESHHOLD); assertEquals( 1.0, uut.intercept(), Equation.THRESHHOLD); assertEquals("1x +1y = 1", uut.toString()); uut = new Equation( 1, -1, 4); assertEquals( 1.0, uut.slope(), Equation.THRESHHOLD); assertEquals(-4.0, uut.intercept(), Equation.THRESHHOLD); assertEquals("1x -1y = 4", uut.toString()); uut = new Equation(-1, 2, -1); assertEquals( 0.5, uut.slope(), Equation.THRESHHOLD); assertEquals(-0.5, uut.intercept(), Equation.THRESHHOLD); assertEquals("-1x +2y = -1", uut.toString()); try { uut = new Equation(1, 0, 1); assertEquals(0.0, uut.slope(), Equation.THRESHHOLD); // exception should occur assertTrue(false); // should not execute this } catch (ArithmeticException e) { // exception is expected assertTrue(e.toString().contains("Infinite Slope")); } try { uut = new Equation(1, 0, 1); assertEquals(0.0, uut.intercept(), Equation.THRESHHOLD); // exception should occur assertTrue(false); // should not execute this } catch (ArithmeticException e) { // exception is expected assertTrue(e.toString().contains("No Unique Intercept")); } } // test cases for solving pairs of equations for x and y public void testSolvingPairs() { try { Equation uut1 = new Equation(1, 1, 4); Equation uut2 = new Equation(1, -1, 2); assertEquals(3.0, uut1.solveForXWith(uut2), Equation.THRESHHOLD); assertEquals(1.0, uut1.solveForYWith(uut2), Equation.THRESHHOLD); assertEquals(3.0, uut2.solveForXWith(uut1), Equation.THRESHHOLD); assertEquals(1.0, uut2.solveForYWith(uut1), Equation.THRESHHOLD); assertTrue(uut1.verifySolution(3.0, 1.0)); assertTrue(uut2.verifySolution(3.0, 1.0)); } catch (ArithmeticException e) { // no exception expected assertTrue(false); // should not execute this } try { Equation uut1 = new Equation(1, 1, 1); Equation uut2 = new Equation(2, 2, 2); assertEquals(0.0, uut1.solveForXWith(uut2), Equation.THRESHHOLD); assertTrue(false); // should not execute this } catch (ArithmeticException e) { // exception is expected assertTrue(e.toString().contains("Parallel Lines")); } try { Equation uut1 = new Equation(1, 1, 1); Equation uut2 = new Equation(1, 1, 3); assertEquals(0.0, uut1.solveForYWith(uut2), Equation.THRESHHOLD); assertTrue(false); // should not execute this } catch (ArithmeticException e) { // exception is expected assertTrue(e.toString().contains("Inconsistent Equations")); } } // test cases for implementing interface Comparable public void testComparability() { Comparable<Equation> uut1 = new Equation(1, 1, 1); Equation uut2 = new Equation(-1, 1, 1); assertEquals(-1, uut1.compareTo(uut2)); assertEquals( 0, uut2.compareTo(uut2)); assertEquals(+1, uut2.compareTo( (Equation) uut1)); // cast uut1 back to what it was born as }
and i have to write some codes that:
Code outside of your Equation class can do the following:
1. Create Equation objects by calling the Equation constructor with three coefficients as arguments, for example:
// create an Equation object to represent: 2x + 3y = 6
Equation myEquation = new Equation(2, 3, 6);
2. Display Equation objects using the toString method, for example:
// print an Equation
System.out.println(myEquation.toString());
3. Get the slope or y-axis intercept for the equation, for example:
// print the slope and intercept for an Equation
System.out.println(myEquation.slope());
System.out.println(myEquation.intercept());
4. Compare Equation objects using the compareTo method, for example:
// compare two equations
if(myEquation.compareTo(yourEquation) < 0)
valid Java statement for when mine is less than yours;
5. Solve a pair of Equations and verify the solution, for example:
// solve a pair of Equations for X (or Y)
double x = myEquation.solveForXWith(yourEquation);
Notice that after code outside of the Equation class creates an Equation object with a given set of coefficients, it does not ever need to access the coefficient values again. So there is no need foraccessor or “getter” methods to get the values of individual coefficients. All operations using the coefficients of Equation objects are done in the code of the Equation class methods, for example:
// part of compareTo - compare the slopes of two objects
double difference = this.slope() – that.slope();
all the information is given on this web site : http://www.cs.umb.edu/~bobw/CS110/Project3/index.html
PLEASE HELP I CANT GET IT TO WORK RIGHT!!