Create accessors for the input and output lists

Assignment Help Computer Engineering
Reference no: EM132105125

The Problem

We start by imaging a database of book titles. One common operation in databases is highlighting search terms. For example, examine this book title :

Of Mice and Men

If we ignore common words (in this case "of" and "and"), we arrive to the keywords "mice" and "men". Given these keywords, we can highlight the search terms by capitalizing them while changing all other terms to lower case. This gives us two version of the title, by capitalizing the significant words in order :

of MICE and men
of mice and MEN

If a word appears more than once on an input line, only the first occurrence needs to be capitalized. Assuming none of its words are common, this book title :

One Fish Two Fish Red Fish Blue Fish

... would generate these highlighted versions :

ONE fish two fish red fish blue fish
one FISH two fish red fish blue fish
one fish TWO fish red fish blue fish
one fish two fish RED fish blue fish
one fish two fish red fish BLUE fish

You are to write a program that reads in all lines from a file, generates several new versions of each line with significant terms capitalized as illustrated here, and writes out the results to a file.

Files will only contain words. There will be no punctuation in the files. Every input line will have at least one word to be capitalized.

Each word on a line is to be separated by a single space. An extra space at the end of a line is permitted.

* Note that I may decide to springboard off of this assignment for your next assignment. Make sure you write clean, readable code, in case you need to use this code again!

Java Code

1. Create the class **SearchTermHighlighter**. All of your code will go into this class.

2. Create two private fields, each an ArrayList of String objects. One will hold the contents of the input file, the other will hold the contents
of the output file.

3. Create accessors for the input and output lists called **getInputFileContents** and **getOutputFileContents**. These methods should *copy* the lists and return the copy, not the field.

4. Create a constructor that takes the name of the input file in a String as the only parameter. The constructor must declare that it *throws FileNotFoundException*.

5. Add code to the constructor to open up a Scanner to parse the file.

Read in the entire file and store its contents in the appropriate ArrayList field.

If the file cannot be opened, then the FileNotFoundException should be thrown by the constructor.

Be sure to close the input file.

6. Create the method **parseContents**. It will take a list of common words in an ArrayList of String objects. It returns nothing.

7. Add code to **parseContents** so that it takes every line input data, highlights each word in turn, and stores new versions of each line following the rules in the problem description above.

8. Create the method **writeFile** that takes the name of the output file in a String as the only parameter and returns nothing.

9. Add code to **writeFile** to have it print out the processed lines containing capitalized words to a file. Like the constructor, it should throw a FileNotFoundException if the PrintWriter could not be created. Be sure to close the output file.

Do not attempt to modify file names or append any kind of directory information.

Reference no: EM132105125

Questions Cloud

Consider health and safety legislation : Why is it necessary to consider health and safety legislation, regulations and requirements in the context of any project work?
Discuss a situation under which it would be advisable : They think that their customers want a checking account summary that looks like the one offered by the other three banks in town.
Describe the most popular earned value system : Describe the most popular earned value system used today and discuss any changes or improvements you would like to see in that earned value system.
Problem early in the software development lifecycle : Why is finding and fixing a problem early in the software development lifecycle - in the requirements specification, for example - much more cost effective
Create accessors for the input and output lists : We start by imaging a database of book titles. One common operation in databases is highlighting search terms.
What is the overall reliability of the system : The parallel components each has a 8/1000 chance for failure. What is the overall reliability of the system?
Execution of the project : In Project management the PM leads the initiation, planning, and execution of the project and the PMO
Part of the project management process : The project is BEST considered in what part of the project management process?
Write a c program that is able to compute areas of circles : Write a C program that is able to compute areas of circles, given the radius of the circle.Have the user input a radius, upon which the area is computed.

Reviews

Write a Review

Computer Engineering Questions & Answers

  Mathematics in computing

Binary search tree, and postorder and preorder traversal Determine the shortest path in Graph

  Ict governance

ICT is defined as the term of Information and communication technologies, it is diverse set of technical tools and resources used by the government agencies to communicate and produce, circulate, store, and manage all information.

  Implementation of memory management

Assignment covers the following eight topics and explore the implementation of memory management, processes and threads.

  Realize business and organizational data storage

Realize business and organizational data storage and fast access times are much more important than they have ever been. Compare and contrast magnetic tapes, magnetic disks, optical discs

  What is the protocol overhead

What are the advantages of using a compiled language over an interpreted one? Under what circumstances would you select to use an interpreted language?

  Implementation of memory management

Paper describes about memory management. How memory is used in executing programs and its critical support for applications.

  Define open and closed loop control systems

Define open and closed loop cotrol systems.Explain difference between time varying and time invariant control system wth suitable example.

  Prepare a proposal to deploy windows server

Prepare a proposal to deploy Windows Server onto an existing network based on the provided scenario.

  Security policy document project

Analyze security requirements and develop a security policy

  Write a procedure that produces independent stack objects

Write a procedure (make-stack) that produces independent stack objects, using a message-passing style, e.g.

  Define a suitable functional unit

Define a suitable functional unit for a comparative study between two different types of paint.

  Calculate yield to maturity and bond prices

Calculate yield to maturity (YTM) and bond prices

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd