Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Make a class that represents a file. This class will have the ability to calculate the number of lines in that file and the ability

Make a class that represents a file. This class will have the ability to calculate the number of lines in that file and the ability to search through the file.

The getNumMatchingWords method will take a bit of text and determine how many lines contain that text. Make the comparison not care about case.

Example: if the user is searching for hello and a line contains the text hello hello hello then this counts as one. Use the contains method defined on Strings to help with this.

Fields

- filename : String

Methods

+ FileStats(filename : String)

+ getNumMatchingWords(key : String) : int

+ getNumLines() : int

Use test case 1 as result

image text in transcribed

Test Case 1 Num lines in Bill of Rights: 65 Vn Num lines in Romeo and Juliet: 5268 in Num lines in dictionary: 21882 In Bill of Rights Test In 'the count: 29 'no' count: 17 in 'rights' count: 2 in -- Romeo and Juliet Test -- 'Romeo' count: 304| 'Juliet' count: 185 ': end' count: 95| 'emoji' count: in In

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