Answered step by step
Verified Expert Solution
Question
1 Approved Answer
org.opentest 4 j . AssertionFailedError: Something went wrong! best i can tell is null at org.junit.jupiter.api.AssertionUtils.fail ( AssertionUtils . java: 3 9 ) at org.junit.jupiter.api.Assertions.fail
org.opentestjAssertionFailedError: Something went wrong! best i can tell is null
at org.junit.jupiter.api.AssertionUtils.failAssertionUtilsjava:
at org.junit.jupiter.api.Assertions.failAssertionsjava:
at MachineTests.testMachineCreationArrayMachineTestsjava: org.opentestjAssertionFailedError: Something went wrong! best i can tell is null
at org.junit.jupiter.api.AssertionUtils.failAssertionUtilsjava:
at org.junit.jupiter.api.Assertions.failAssertionsjava:
at MachineTests.testMachineTurnValidMachineTestsjava: How to fix these issues here is my code import java.util.List;
import java.util.ArrayList;
public class Machine
private int ans;
private List verifierss;
public Machineint ans, Verifier verifierss throws IncorrectDataException
correctAnsans;
this.ans ans;
this.verifierss List.ofverifierss;
public Machineint ans, List verifierss throws IncorrectDataException
correctAnsans;
this.ans ans;
this.verifierss new ArrayListverifierss;
private void correctAnsint ans throws IncorrectDataException
if anslength
throw new IncorrectDataExceptionAnswer must consist of exactly digits.";
for int n : ans
if n n
throw new IncorrectDataExceptionDigits must be within the range ;
public String toString
StringBuilder stringbuilder new StringBuilderVerifiers:
;
char verifierCh A;
for Verifier verifier : verifierss
stringbuilder.appendverifierChappendappendverifiertoStringappend
;
verifierCh;
return stringbuilder.toStringtrim;
public String turnint guess, char verifierChoice throws IncorrectDataException
correctGuessguess;
if verifierChoicelength
throw new IncorrectDataExceptionThere must be exactly selected verifiers.";
StringBuilder stringbuilder new StringBuilderResults for guess ;
for int n : guess
stringbuilder.appendn;
stringbuilder.append:
;
List sortedChoice new ArrayList;
for char c : verifierChoice
sortedChoice.addCharactertoUpperCasec;
sortedChoice.sortCharacter::compareTo;
for char choicee : sortedChoice
int i choicee A;
if i i verifierss.size
throw new IncorrectDataExceptionSelected verifier is out of bounds.";
Verifier verifier verifierss.geti;
stringbuilder.appendchoiceeappendappendverifiercheckguess ansappend
;
return stringbuilder.toStringtrim;
public String turnint guess, String verifierChoice throws IncorrectDataException
char choiceArray verifierChoice.replacetoCharArray;
return turnguess choiceArray;
public boolean finalGuessint guess throws IncorrectDataException
correctGuessguess;
for int i ; i guess.length; i
if guessi ansi
return false;
return true;
private void correctGuessint guess throws IncorrectDataException
if guesslength
throw new IncorrectDataExceptionGuess must consist of exactly digits.";
for int n : guess
if n n
throw new IncorrectDataExceptionDigits must be within the range ;
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started