How do I code the interfaces, classes and JUnit 4 tests in java? this is all the information given below: A sentence in English is made of several words in a particular sequence. You must represent such a sentence as a list of words. Much like the list example we saw in class, this one is made of nodes (represented by a Sentence interface). There is one word per node, called WordNode. The sentence may also contain zero or more punctuation marks, which are represented by a PunctuationNode. The end of the sentence is denoted by a special empty node, called EmptyNode. Define the following operations for such a list of words: A method getNumberOfWords that computes and returns the number of words in a sentence. The punctuation does not count as a word. This method should answer/return an int. A method longestWord that determines and returns the longest word in a sentence. The word returned is just the word, and should not begin or end with punctuation. If the sentence contains no words, longestWord should return an empty string. This method should answer/return a String A method toString that will convert the sentence into one string. There must be a space between every two words. A punctuation mark should have no space between it and whatever precedes it. There is no space between the last word and the end of this sentence. If there is no punctuation mark at the end of the sentence, this string should end with a period (this method should NOT add a period to the original sentence object, but the String answered by this method should properly have the period) This method should answer/return a String A method clone() that returns a duplicate of a given sentence. A duplicate is a list that has the same words and punctuation in the same sequence, but is independent of the original list. This method should answer/return a Sentence A method merge(Sentence other) that will merge two sentences into a single sentence. The merged list should preserve all the punctuation. The merged list should be returned by this method, and the original lists should be unchanged. This method should answer/return a Sentence 1.2  What to do Design the interfaces and classes that you need for this purpose. We are purposely NOT giving you the interface code as a "starter pack". Develop your interface for Sentence by extracting the concepts from the specification above in Section 1.1 In a JUnit test class, create examples of sentences and write tests for each operation. Design the fields and methods for your classes, and verify that your tests pass on them. Check if you can abstract any common parts of your design/code. If so, take a "bottom up" approach and push these common features into an appropriate superclass

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

How do I code the interfaces, classes and JUnit 4 tests in java? this is all the information given below:

A sentence in English is made of several words in a particular sequence. You must represent such a sentence as a list of words. Much like the list example we saw in class, this one is made of nodes (represented by a Sentence interface). There is one word per node, called WordNode. The sentence may also contain zero or more punctuation marks, which are represented by a PunctuationNode. The end of the sentence is denoted by a special empty node, called EmptyNode.

Define the following operations for such a list of words:

  • A method getNumberOfWords that computes and returns the number of words in a sentence. The punctuation does not count as a word. This method should answer/return an int.

  • A method longestWord that determines and returns the longest word in a sentence. The word returned is just the word, and should not begin or end with punctuation. If the sentence contains no words, longestWord should return an empty string.
    This method should answer/return a String

  • A method toString that will convert the sentence into one string. There must be a space between every two words. A punctuation mark should have no space between it and whatever precedes it. There is no space between the last word and the end of this sentence. If there is no punctuation mark at the end of the sentence, this string should end with a period (this method should NOT add a period to the original sentence object, but the String answered by this method should properly have the period)
    This method should answer/return a String

  • A method clone() that returns a duplicate of a given sentence. A duplicate is a list that has the same words and punctuation in the same sequence, but is independent of the original list.
    This method should answer/return a Sentence

  • A method merge(Sentence other) that will merge two sentences into a single sentence. The merged list should preserve all the punctuation. The merged list should be returned by this method, and the original lists should be unchanged.
    This method should answer/return a Sentence

1.2  What to do
  1. Design the interfaces and classes that you need for this purpose. We are purposely NOT giving you the interface code as a "starter pack". Develop your interface for Sentence by extracting the concepts from the specification above in Section 1.1

  2. In a JUnit test class, create examples of sentences and write tests for each operation.

  3. Design the fields and methods for your classes, and verify that your tests pass on them.

  4. Check if you can abstract any common parts of your design/code. If so, take a "bottom up" approach and push these common features into an appropriate superclass

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 4 steps

Blurred answer
Knowledge Booster
Generic Type
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education