Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

1. Create a functional interface called Wordable with the abstract function the following signature: String createString(String s, int n) 2. Create a class called Dictionary.

1. Create a functional interface called Wordable with the abstract function the following signature:

String createString(String s, int n)

2. Create a class called Dictionary.

Dictionary has the following List of words found at the end of this document (English words that begin with the letters "ja").

Dictionary has a method with the following signature:

public String getWords(String word, int number, Wordable w)

3. Create a class called Main.

Main has a main method which does the following:

main() creates a Wordable variable called wordy and assigns it a lambda expression as follows:

a) If the first commandline argument is "concat" then Wordable returns a String with all the words concatenated together; for example: "jabjabbedjabberjabbered..."

b) If the first commandline argument is "repeat" then Wordable returns a String with all the words concatenated together, each word repeated args[1] times (the second commandline argument must be a number, which can be read by the code Integer.valueOf(args[1])); for example, if args[1] is 2, Wordable returns "jabjabjabbedjabbedjabberjabberjabberedjabbered..."

c) If the first commandline argument is "nth" then Wordable returns the nth word from your list of words (the second commandline argument must be a number - the index; for example, if args[1] is 6, Wordable returns "jabberwocky", given the following list:

The list of words (see below) is:

index 0: jab

index 1: jabbed

index 2: jabber

index 3: jabbered

index 4: jabbering

index 5: jabbers

index 6: jabberwocky

index 7: jabbing

etc...

d) If the first commandline argument is "reverse", then Wordable returns a String with all the words concatenated together but each word is in reverse order; for example: "bajdebbajrebbajderebbaj..."

e) At the end of main(), print the String returned by Wordable. Then use a method reference to print the entire list of words.

Here is the list of words you must use:

jab

jabbed

jabber

jabbered

jabbering

jabbers

jabberwocky

jabbing

jabot

jabots

jabs

jacaranda

jacarandas

jacinth

jack

jackal

jackals

jackanapes

jackanapeses

jackass

jackasses

jackboot

jackboots

jackdaw

jackdaws

jacked

jacket

jacketed

jacketing

jackets

jackhammer

jackhammers

jackie

jacking

jackknife

jackpot

jackpots

jacks

jackson

jacksonville

jaclyn

jacob

jacobean

jacobian

jacobin

jacobins

jacobite

jacobites

jacobs

jacquard

jacquards

jacqueline

jacques

jactitation

jactitations

jactus

jacuzzi

jacuzzis

jade

jaded

jadeite

jadeites

jades

jading

jaeger

jaffa

jag

jagged

jaggedly

jaggedness

jagger

jags

jaguar

jaguars

jai

jail

jailed

jailer

jailers

jailhouse

jailing

jailor

jailors

jails

jaipur

jakarta

jake

jalopies

jalopy

jalousie

jalousies

jam

jamaica

jamaican

jamaicans

jamb

jamboree

jamborees

jambs

james

jamey

jamie

jammed

jamming

jammy

jams

jan

jane

janeiro

janet

jangle

jangled

jangles

jangling

janice

janitor

janitorial

janitors

january

januarys

janus

japan

japanese

japanned

japanning

japans

jape

japed

japer

japers

japery

japes

japing

japonica

japonicas

jar

jardiniere

jardinieres

jarful

jarfuls

jargon

jargons

jarred

jarring

jarringly

jarrow

jars

jasmine

jasmines

jason

jasper

jaspers

jaundice

jaundiced

jaunt

jaunted

jauntier

jauntiest

jauntily

jaunting

jaunts

jaunty

java

javanese

javelin

javelins

jaw

jawbone

jawbones

jawboning

jawbreaker

jawbreakers

jawed

jawing

jaws

jay

jays

jayvees

jaywalk

jaywalked

jaywalker

jaywalkers

jaywalking

jaywalks

jazz

jazzed

jazzes

jazzier

jazziest

jazzing

jazzman

jazzmen

jazzy

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions