Question: how do i code this in java? Now that we've looked under the hood and understand the theory of recursive data structures, we'll move on
how do i code this in java?
Now that we've "looked under the hood" and understand the theory of recursive data structures, we'll move on to utilizing the Java (generic) implementation of these collections, along with higher-order functions. A higher order function is a function that takes another function as one of its arguments. The higher order function then executes the given function as part of its implementation. Examples include: fold (aka reduce), producing a single summary value from a collection of items (e.g. count(); filter, returning a subset of items (e.g., books published before 2000); and map, producing corresponding items by performing an operation on each original item (e.g., the titles of the books). 1.2 What to do We will re-implement Words in a Sentence from Lab 3. However, Instead of building a List from scratch, we'll be using the Java Collections List generics covered in class last week. Start by creating a Sentence solution with List (you can use the Java LinkedList or ArrayList implementation). Since you are using the Java List you do NOT need to implement a recursive solution and there is no need for an EmptyNode. In addition to the methods you implemented before (getNumberOfWords, longestword, toString, clone, merge) Add the following operations to your new solution: 1. Write a method that counts and returns the number of punctuation in a given sentence. Express this as a higher-order function and implement it. 2. Write a method that counts and returns the number of words in the sentence that have the letter 'z' in them. Express this as a higher-order function and implement it. Write tests for both methods. When calling these methods, try to express the functions you pass to them in lambda function notation. 1.3 A fun language If you recently ate at Chipotle, you may have received a brown paper bag with gibberish letters written on it: "AKINGMAY AWAY IGPAY EALDAY ABOUTWAY IGPAY ATINLAY". In fact this message is written in Piglatin, a simple but fictitious language. Piglatin converts a word in English using the following two rules: 1. If the letter begins with a vowel, then WAY" is appended to the word. 2. If the letter begins with a consonant (a letter other than a vowel), then the first letter of the word is moved to the end, and then "AY" is appended to it. Using these rules, one can decode the Chipotle message to "MAKING A PIG DEAL ABOUT PIG LATIN". 1.4 What to do 1. Write a method that codes and returns an English sentence in Piglatin. Write tests for this method. 1.5 Thought Exercise/Challenge Question: Abstraction You won't be graded on this portion so think of it as a "stretch goal" to help you expand your understanding