Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

this is what i have so far this is what im testing assertTrue(init.toString().equals(The value is: 0)); here is my code the equals works im trying

this is what i have so far

this is what im testing assertTrue(init.toString().equals("The value is: 0"));

here is my code the equals works im trying to get toString to work, any advice is appreciated.

import framework.problem.State; import java.util.stream.Stream;

public class ArithmeticState implements State { public ArithmeticState(int contents) { this.contents = contents; }

@Override public boolean equals(Object other) { ArithmeticState otherArithmetic = (ArithmeticState) other; if (this.contents == (otherArithmetic.contents)) return true; else return false; }

@Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append("The value is:"); sb.append(this.contents); return sb.toString();

} private final int contents;

private static final String NEW_LINE = " "; }

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions