Course Solutions Uncategorized (Solved) : Fix Code Passes Test Test Method Number 1 Test Method Public Void Testisvalidword Assertfa Q28095947 . . . .

(Solved) : Fix Code Passes Test Test Method Number 1 Test Method Public Void Testisvalidword Assertfa Q28095947 . . . .

 

How do I fix my code, so it passes all of the test in the testmethod

Number 1)****************************testmethod******************************************

public void testIsValidWord() {
assertFalse(Hangman.isValidWord(“Cool”));//false because only 4letters
assertTrue(Hangman.isValidWord(“anxiety”));
assertFalse(Hangman.isValidWord(“aapaple”));//false because thereare 3 As
assertFalse(Hangman.isValidWord(“renovate the room”));//fallbecause there are spaces
}

*************************************************************************

my code

*************************************************************8

public static boolean validW(String word) {

int alphOccur=0;

boolean flag=true;

for(int i=0;i<word.length()-1;i++) {

if(word.charAt(i)>=’a’&&word.charAt(i+1)<=’z’||word.charAt(i)>=’A’&&word.charAt(i+1)<=’Z’){

flag = true;

}

if(alphOccur+1 >=3) {

flag=false;

}

for(int j=i+1;j<word.length()-i;j++) {

if(word.charAt(i)==word.charAt(j)) {

alphOccur++;

}

}

}

if(word.length()>=6) {

flag=true;

}

System.out.println(flag);

return flag;

}

————–Number2———————————————————————————————————

//how do i

//test method

public void testMakeGuess() {
assertEquals(“optio_”, Hangman.makeGuess(“g”, “option”,”optio_”));
assertEquals(“option”, Hangman.makeGuess(“n”, “option”,”optio_”));
assertEquals(“opt___”, Hangman.makeGuess(“opt”, “option”,”______”));
assertEquals(“_p_ion”, Hangman.makeGuess(“ion”, “option”,”_p____”));
assertEquals(“option”, Hangman.makeGuess(“pt”, “option”,”op_ion”));
}

//my code

/*the disguisedWord is the blank string with underscores like __ _ _ _ _ _, everytime a user guess a letter, if the letter is inthe secretWord, it it assign the letter at

OR

PayPal Gateway not configured

OR

PayPal Gateway not configured

Leave a Reply

Your email address will not be published. Required fields are marked *

Related Post

(Answered) : Question 4 2 Points Political Systems Based Promote Principle Government May Intervene Ens Q36058976(Answered) : Question 4 2 Points Political Systems Based Promote Principle Government May Intervene Ens Q36058976

<br/><img src="https://media.cheggcdn.com/media%2F1a0%2F1a0a18af-5dad-482a-a95d-fa42bc7ff303%2Fimage.png" alt="Question 4 (2 points) Political systems based on the promote the principle that government may intervene to ensure that busin" aria-describedby="j1t"/>Question 4 (2 points) Political systems based on