Java Word Processor

Java Word Processor

Problem: Design and implement a class called WordProcessor. This class is

used to:

? hold a line of text that can be manipulated in various ways

? perform various manipulations and modify the text

? return a string with a list of all the palindromes in the text (a palindrome

reads the same forwards as backwards)

? return a Pig Latin version of the text (see description below)

? return several counts about the text

o number of words (a hyphenated word is one word),

o number of sentences (ends in a period),

o number of questions (ends in a question mark),

o number of exclamations (ends in an exclamation mark!),

Helpful information and requirements for your WordProcessor class - you must

name your methods exactly as shown here:

? You can break up a String into words or "tokens" by using java?s Scanner

class. When constructing your Scanner, you will pass a String as a

parameter (not System.in). The Scanner methods necessary to break it

up are hasNext() and next(). See the ScannerDemo.java posted on our

class webpage to see how this works.

? Legal punctuation for the text is periods, question marks, exclamation

marks, hyphens (within a word), and apostrophes. Words will have only a

single space between them.

? Your class should have 2 constructors: one that has no parameters and

a second one that takes a line of text as a parameter. Each constructor

should initialize all instance variables.

? Write a public method setText that takes a String parameter and changes

the current text to this new String. If no text existed before, this sets it. If

there was text, this method will overwrite it. It doesn't return anything.

? Write a public method toString that takes no parameters but returns the

current version of the text.

? Write public methods getNumberOfWords, getNumberOfSentences,

getNumberOfQuestions, getNumberOfExclamations that return the counts

of how often each of these things occur in the text.

? Write a public method replaceWord that takes two String parameters. The

first parameter is the word to replace, the second parameter is what

to replace it with in the text. All occurrences of the first word should be

changed to the second. This method does not return anything. You

may not use the String method replace, replaceAll, or

replaceFirst :-).

? Write a public method appendText that takes a String parameter and

appends (adds it to the end) it to the current text. If no text existed before,

this sets it. It doesn't return anything.

? Write a public method getPalindromes that takes no parameters, but

returns a String that has all the words in the text that are palindromes

concatenated together, each one separated by a space. A palindrome

reads the same forward as backwards ignoring case and internal

punctuation). For example: noon, Sara?s, radar are all palindromes.

? Write a public method getPigLatinVersion that takes no parameters, but

returns the Pig Latin translation of the text. This method does not modify

or change the original text. You may want to have one or more "private"

methods to help this method do its work. To convert a word to Pig Latin:

o if the word begins with a vowel (a, e, i, o, u), then just add ?ay? at the

end of the word.

o if the word begins with one or more consonants, move all initial

consonants (up to the first vowel) to the end of the word and add ?ay? at

the end.

o if the word is all consonants, then just add ?ay? at the end.

o leave any internal punctuation (apostrophes and hyphens) where it is

in the original string. For example Sara?s becomes Ara?ssay

o word separators such as commas, periods, etc. should not be included

in the middle of a Pig Latin version of a word but should occur after the

word as before.

o if the original first letter of a word is capitalized, the Pig Latinized

version of the word should also begin with a capital letter.

Hints:

? Start early! This assignment will take some involved problem solving

techniques.

? Work up your solution incrementally as we've discussed in class. For

example, initially make sure that each of your constructors work. Then add

other methods such as the number of words, sentences, etc.

? If you?re having trouble making it work with capitalization and punctuation,

use a simplified input with all lower case letters and no punctuation, then

work up from there.

? You should always have a compiling, working class at each stage of

development.

? Ask questions!

View Answers

Ads









Related Tutorials/Questions & Answers:
Java Word Processor
Java Word Processor  Problem: Design and implement a class called... of words (a hyphenated word is one word), o number of sentences (ends...: ? You can break up a String into words or "tokens" by using java?s Scanner
String file in to word file in java
String file in to word file in java  How to convert a String format notepad file into Ms word file in java
Advertisements
String file in to word file in java
String file in to word file in java  how to convert a String format word file into Ms Word file using java? please can anyone of you help me
Java code to convert pdf file to word file
Java code to convert pdf file to word file  How to convert pdf file to word file using Java
java code to open and display MS-word document
java code to open and display MS-word document  java code to open and display MS-word document
How to merge two word document using java
How to merge two word document using java   how to merge two word document using java
How to merge two word document using java
How to merge two word document using java   how to merge two word document using java
Write a program in JAVA which accepts a sentence & displays the longest word in the sentence alongn with it length of the word.
Write a program in JAVA which accepts a sentence & displays the longest word in the sentence alongn with it length of the word.  **A program in JAVA which accepts a sentence & displays the longest word in the sentence along
convert date month and year into word using java
;continue.... public void pass(int number) { int word, q...; if (word == 0) { q = number / 10...convert date month and year into word using java  convert the date
convert date month and year into word using java
;continue.... public void pass(int number) { int word, q...; if (word == 0) { q = number / 10...convert date month and year into word using java  convert the date
convert date month and year into word using java
convert date month and year into word using java  convert the date, month,year into word like 12-3-2012 into twelve march two thousands twelve pls send the code write in java.   Visit Here
convert date month and year into word using java
convert date month and year into word using java  convert the date, month,year into word like 12-3-2012 into twelve march two thousands twelve pls send the code write in java.   Visit Here
convert date month and year into word using java
convert date month and year into word using java  convert the date, month,year into word like 12-3-2012 into twelve march two thousands twelve pls send the code write in java.   Visit Here
Java word extraction program. - Java Beginners
Java word extraction program.  Need to code a public class named...- character word. The starting position should be based on the leftmost character... position and display the word on the console screen. Thanks
convert date month and year into word using java
Java Date Month Format  convert the date, month,year into word like 12-3-2012 into twelve march two thousands twelve pls send the code write in java.   Visit Here
convert date month and year into word using java
convert date month and year  convert the date, month,year into word like 12-3-2012 into twelve march two thousands twelve pls send the code write in java.   Visit Here
convert date month and year into word using java
convert date month and year Java  convert the date, month,year into word like 12-3-2012 into twelve march two thousands twelve pls send the code write in java.   Visit Here
convert date month and year into word using java
Match Date format  convert the date, month,year into word like 12-3-2012 into twelve march two thousands twelve pls send the code write in java.   Visit Here
convert date month and year into word using java
Date Format in Jave  convert the date, month,year into word like 12-3-2012 into twelve march two thousands twelve pls send the code write in java.   Visit Here
convert date month and year into word using java
Basic format for Date and Month  convert the date, month,year into word like 12-3-2012 into twelve march two thousands twelve pls send the code write in java.   Visit Here
convert date month and year into word using java
Convert Date Month format  convert the date, month,year into word like 12-3-2012 into twelve march two thousands twelve pls send the code write in java.   Visit Here
convert date month and year into word using java
Convert Date Format  convert the date, month,year into word like 12-3-2012 into twelve march two thousands twelve pls send the code write in java.   Visit Here
Merge multiple jasper file to one word Doc using java
Merge multiple jasper file to one word Doc using java   how to Merge multiple jasper file to one word Doc using java
how to translate english word to marathi using java
how to translate english word to marathi using java  I want to translat english word to marathi,how i can develop a code for that ,please sajest me
Auto complete of word search using ajax with java
Auto complete of word search using ajax with java  I want to display the list of words when I type the first letter of the word in a text box. I am using jsp to design the form. I want ajax sample to achieve this feature. Its
Auto complete of word search using ajax with java
Auto complete of word search using ajax with java  I want to display the list of words when I type the first letter of the word in a text box. I am using jsp to design the form. I want ajax sample to achieve this feature. Its
Edit word document Headers and Footers using POI Library in java?
Edit word document Headers and Footers using POI Library in java?  Hi All, I need code to modify the Header and Footer contents of a ms-word template using POI or JACOB libraries. Could any one help me? Thanks Advance
Compare two word file
Compare two word file  How to compare two word file using Java
Execute the java program using one processor
Execute the java program using one processor   Write a program to print the number series 1, 2,3, 4ΓΆβ?¬Β¦.100 using java programming language in dual core computer a) Execute the program using one processor b) Execute
open word document
open word document  how to open a word document ??   Please go through the following link: Java Read word document file The above link will provide an example that will read the document file using POI library in java
open word document
open word document  how to open a word document ??   Please go through the following link: Java Read word document file The above link will provide an example that will read the document file using POI library in java

Ads