Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I dont know why my if statement in freqWord isnt recoginizing the parameter. newText is a hashmap which stored all words from a text and

I dont know why my if statement in freqWord isnt recoginizing the parameter. newText is a hashmap which stored all words from a text and freqWprd is count the occurences of the (Word ow) in the text. My method only returns 0, how do I fix it so it recognize on when to return 1 and when to return 0?. Thanks in advance.

test case:

public void testFreqWord() { assertEquals(1, bm.wordData.freqWord(new Word("EACH"))); assertEquals(0, bm.wordData.freqWord(new Word("THERE"))); }

-------------------------------------------------------------------------

public int freqWord(Word ow) { if(newText.containsKey(ow)) { return 1; } else { return 0; } }

--------------------------------------------------Word Class

public class Word {

/** Declare instance variables. */ public String word; /** * Default constructor. Initialize the instance variables in this method. * */ public Word(String w) { word= new String(w); }

/** You may add more methods needed to complete the program */ public int WordCount(String s) { if(s==word) return 1; return 0; } public int wordLength() { return word.length(); } }

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_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

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

Get Started

Recommended Textbook for

Datacasting How To Stream Databases Over The Internet

Authors: Jessica Keyes

1st Edition

007034678X, 978-0070346789

More Books

Students also viewed these Databases questions