public class FindLine
extends java.lang.Object
The provided code is incomplete. Modify it so that it works properly and passes the unit tests in
FindLineTest.java
.
Constructor and Description |
---|
FindLine() |
Modifier and Type | Method and Description |
---|---|
static void |
main(java.lang.String[] unused)
Solicits a single word from the user at the command line and searches for it in the Bill of
Rights (BillOfRights.txt).
|
static void |
printMatchingLines(java.lang.String searchWord,
java.lang.String corpus)
Find word in multi-line string and print matching lines and line numbers.
|
public static void printMatchingLines(java.lang.String searchWord, java.lang.String corpus)
For example, given the string:
Hello, there! I'm here. You're there. Therefore, we're near.
If the search term is "there" or "There" or "THERE", the following lines should be printed:
1: Hello, there! 3: You're there.
If the search term is "I'm" or "i'm", the following lines should be printed
"2: I'm here."
Here are some things to keep in mind:
Also note the leading space after the line number and colon:
(number): (line contents)
Your solution must match the expected output exactly, otherwise you will not receive credit.
Complete the Javadoc comment for this function and write it.
searchWord
- word to search forcorpus
- the multi-line text to search throughpublic static void main(java.lang.String[] unused) throws java.io.FileNotFoundException
You are free to review this function, but should not modify it. Note that this function is not tested by the test suite, as it is purely to aid your own interactive testing.
unused
- unused input argumentsjava.io.FileNotFoundException
- exception if the text file cannot be located