For all questions in this problem, be sure to follow the design recipe carefully: Give sufficient...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
For all questions in this problem, be sure to follow the design recipe carefully: Give sufficient examples of data, and sufficient tests, to test your methods thoroughly. . If you find yourself wanting to use a field-of-field or getters, stop. Fill out the template for each method, and figure out another design. Think carefully about how to use dynamic dispatch, and where to define methods, to keep your code as simple and clean as possible. Note: The following method defined for the class String may be useful: // does this String come before the given String lexicographically? // produce value < 0 if this String comes before that String // produce value zero // produce value > 0 if this String is the same as that String if this String comes after that String int compareTo(String that) In a future assignment, we will be creating a game that deals with lists of words. A word can be active or inactive in the game so we come up with the following definitions for a list of words: Related files: --- ILoWord.java In this assignment, we will implement some methods for lists of words. Some of these may be relevant to the later game assignment, others are for practice. All of the following methods should be defined in I Loword. You may need to design helpers for some of the methods as well. Design the method sort that produces a new list, with words sorted in alphabetical order, treating all Strings as if they were given in all lowercase. You may use insertion sort as we did in lecture. Note: The String class defines the method to LowerCase that produces a String just like the one that invoked the method, but with all uppercase letters converted to lowercase. Design the method is Sorted that determines whether this list of Iwords has words sorted in alphabetical order, in a case-insensitive way. Hint: You will likely need a helper method. You may want to review the accumulator style functions we have seen in DrRacket. Design the method interleave that takes this list of IWords and a given list of Iwords, and produces a list where the first, third, fifth... elements are from this list, and the second, fourth, sixth... elements are from the given list. Any "leftover" elements (when one list is longer than the other) should just be left at the end. Design the method merge that merges this sorted list of IWords and a given sorted list of IWords, and produces a sorted list of Iwords that contains all items in both original lists, including duplicates, treating all Strings as if they were given in all lowercase. You should not use sort for this. (This is not the same computation as for interleave, but the two methods are similar. Can you construct an example of two lists such that interleaving them and merging them produce different results? Can you construct another example where the two results are the same?) Design the method checkAndReduce which takes in a string of length 1 and produces an I Loword where any active words in this I LoWord are reduced by removing the first letter only if the given string matches the first letter. Design the method addToEnd that takes in an Iword and produces an ILoWord that is like this I Loword but with the given IWord added at the end. Design the method filterOut Empties that produces an ILoWord with any IWords that have an empty string are filtered out. Design the method draw that takes in a WorldScene and draws all of the words in this ILoWord onto the given WorldScene. Review The Image Library to learn about making a Text Image to display text and the place ImageXY method to place an image on a WorldScene. Choose colors for the background and the words. Active words and inactive words should be different colors. Choose sizes for the background and for the font for words. import tester.Tester; //represents a list of words interface ILoWord { } //represents an empty list of words class MtLoWord implements ILoWord { } class ConsLoWord implements ILoWord { IWord first; ILoWord rest; } ConsLoWord (IWord first, I LoWord rest) { this.first = first; this.rest = rest; //represents a word in the ZType game interface IWord { } } } // represents an active word in the ZType game class ActiveWord implements IWord { String word; } int x; int y; ActiveWord (String word, int x, int y) { this.word= word; this.x = x; this.y = y; } //represents an inactive word in the ZType game class InactiveWord implements IWord { String word; int x; int y; InactiveWord (String word, int x, int y) { this.word = word; } this.x = x; this.y = y; //all examples and tests for ILoWord class ExamplesWordLists { For all questions in this problem, be sure to follow the design recipe carefully: Give sufficient examples of data, and sufficient tests, to test your methods thoroughly. . If you find yourself wanting to use a field-of-field or getters, stop. Fill out the template for each method, and figure out another design. Think carefully about how to use dynamic dispatch, and where to define methods, to keep your code as simple and clean as possible. Note: The following method defined for the class String may be useful: // does this String come before the given String lexicographically? // produce value < 0 if this String comes before that String // produce value zero // produce value > 0 if this String is the same as that String if this String comes after that String int compareTo(String that) In a future assignment, we will be creating a game that deals with lists of words. A word can be active or inactive in the game so we come up with the following definitions for a list of words: Related files: --- ILoWord.java In this assignment, we will implement some methods for lists of words. Some of these may be relevant to the later game assignment, others are for practice. All of the following methods should be defined in I Loword. You may need to design helpers for some of the methods as well. Design the method sort that produces a new list, with words sorted in alphabetical order, treating all Strings as if they were given in all lowercase. You may use insertion sort as we did in lecture. Note: The String class defines the method to LowerCase that produces a String just like the one that invoked the method, but with all uppercase letters converted to lowercase. Design the method is Sorted that determines whether this list of Iwords has words sorted in alphabetical order, in a case-insensitive way. Hint: You will likely need a helper method. You may want to review the accumulator style functions we have seen in DrRacket. Design the method interleave that takes this list of IWords and a given list of Iwords, and produces a list where the first, third, fifth... elements are from this list, and the second, fourth, sixth... elements are from the given list. Any "leftover" elements (when one list is longer than the other) should just be left at the end. Design the method merge that merges this sorted list of IWords and a given sorted list of IWords, and produces a sorted list of Iwords that contains all items in both original lists, including duplicates, treating all Strings as if they were given in all lowercase. You should not use sort for this. (This is not the same computation as for interleave, but the two methods are similar. Can you construct an example of two lists such that interleaving them and merging them produce different results? Can you construct another example where the two results are the same?) Design the method checkAndReduce which takes in a string of length 1 and produces an I Loword where any active words in this I LoWord are reduced by removing the first letter only if the given string matches the first letter. Design the method addToEnd that takes in an Iword and produces an ILoWord that is like this I Loword but with the given IWord added at the end. Design the method filterOut Empties that produces an ILoWord with any IWords that have an empty string are filtered out. Design the method draw that takes in a WorldScene and draws all of the words in this ILoWord onto the given WorldScene. Review The Image Library to learn about making a Text Image to display text and the place ImageXY method to place an image on a WorldScene. Choose colors for the background and the words. Active words and inactive words should be different colors. Choose sizes for the background and for the font for words. import tester.Tester; //represents a list of words interface ILoWord { } //represents an empty list of words class MtLoWord implements ILoWord { } class ConsLoWord implements ILoWord { IWord first; ILoWord rest; } ConsLoWord (IWord first, I LoWord rest) { this.first = first; this.rest = rest; //represents a word in the ZType game interface IWord { } } } // represents an active word in the ZType game class ActiveWord implements IWord { String word; } int x; int y; ActiveWord (String word, int x, int y) { this.word= word; this.x = x; this.y = y; } //represents an inactive word in the ZType game class InactiveWord implements IWord { String word; int x; int y; InactiveWord (String word, int x, int y) { this.word = word; } this.x = x; this.y = y; //all examples and tests for ILoWord class ExamplesWordLists {
Expert Answer:
Related Book For
Posted Date:
Students also viewed these algorithms questions
-
Planning is one of the most important management functions in any business. A front office managers first step in planning should involve determine the departments goals. Planning also includes...
-
THIRD AVENUE SOFTWARE HEALTH-CARE APP PROJECT This case is new for the ninth edition of Information Technology Project Management . The case provides an opportunity to apply agile and Scrum...
-
a) which ionization gives the best sensitivity the analysis of chloramphenicol? b) The compound with highest retention factor? c) What is the resolution between yohimbine and chloramphenicol? d) What...
-
Have you ever listened for an approaching train by kneeling next to a railroad track and putting your ear to the rail? Young's modulus for steel is Y = 2.0 1011 N/m2, and the density of steel is r =...
-
For all nonhomicide offenses, there are five general elements of duress: (1) The defendant acted under the compulsion or threat of imminent infliction of death or great bodily injury; (2) the...
-
The space to the right of the \(y\) axis in Figure P29.28 contains a uniform magnetic field of unknown magnitude that points in the positive \(z\) direction. As a conducting square loop placed in the...
-
Using the earnings data developed in E3-1 and assuming that this was the first week of employment for R. Herbert with Crestview Manufacturing Co., prepare the journal entries for the following: a....
-
Kazibwe, a businessman does not maintain a complete set of books for his business transactions. The following is a summary of his cash transactions for the year ended December 31, 2015. Receipts Kshs...
-
John Parsons (123-45-6781) and George Smith (123-45-6782) are 70% and 30% owners, respectively, of Premium, Inc. (11-1111111), a candy company located at 1005 16th Street, Cut and Shoot, TX 77303....
-
Vo start from a vector 3 (-) -1 2 Write this vector as a linear combination of eigenvectors. 2.Find an expression for M vo for an arbitrary positive integer n. What happens when n ?
-
Company A's financial data are shown below. Year 2015 2020 Year 2015 2020 Sales 3,476 4,693 Total assets 3,540 5,054 Cost of goods sold 1,972 2,412 SGA expenses 599 865 903 1,170 Accounts Inventories...
-
Below is the C++ program for the implementation of a particular data structure (25 points). 1. First, describe in detail which type of data structure is used in the following C++ program and which...
-
The "Home" country has 1200 units of labor at its disposal. It can produce two goods: apples and bananas. To produce 1 kg of apples, 3 units of labor are required, for 1 kg of bananas, 2 units of...
-
Sheridan, Inc. is considering the purchase of a warehouse directly across the street from its manufacturing plant. Sheridan currently warehouses its inventory in a public warehouse across town. Rent...
-
I. II. Executive Summary and Background Information This section should be a succinctly written management summary, about one page in length or less, that summarizes the project proposal in such a...
-
3. Identify the type of retirement account that provides the annuitant with the greatest access to funds? options: A Reverse Mortgage A Registered Life Annuity A Life Income Fund A Retirement Income...
-
Design a circuit which negative the content of any register and store it in the same register.
-
Left-tailed test; = 0.05 Find the critical z values for the given conditions. In each case assume that the normal distribution applies, so Table A-2 can be used. Also, draw a graph showing the...
-
Test the claim that the sequence of World Series wins by American League and National League teams is random. Given below are recent results with American and National league teams represented by A...
-
Use the given data to find the equation of the regression line. x 2 3 5 5 10 y 6 0 15 5 2
-
Every financial advisor has a strategy for predicting the direction of the stock market. Most focus on fundamental economic data, such as interest rates and corporate profits. But an alternative...
-
State whether the prediction (or implied prediction) should be trusted in each of the following cases, and explain why or why not. a. Youve found a best-fit line for a correlation between the number...
-
Figure 20 shows data and best-fit lines for both mens and womens world record times in the 1-mile race. Based on these data, predict when the womens world record will be faster than the mens world...
Study smarter with the SolutionInn App