Answered step by step
Verified Expert Solution
Question
1 Approved Answer
This project implements an interface and follows Array collections. With Array collections there are methods used such as toString() or something like isFull(). Helper methods
This project implements an interface and follows Array collections. With Array collections there are methods used such as toString() or something like isFull(). Helper methods can be used for the class as well
Everything for a reference to this will be below
The collectgion implements the interface
LinkedCollection
public class LinkedCollection implements CollectionInterface { //********************************************************************************* ***** Inner Node Class private class Node { E data; Node next; Node(E data) { this(data, null); } Node(E data, Node next) { this.data = data; this.next = next; } //================================== Helper } //********************************************************************************* ***** //================================================================================= ===== Properties private int size; private Node head; //================================================================================= ===== Constructors public LinkedCollection() { } //================================================================================= ===== Methods @Override public boolean add(E o) { return false; } @Override public boolean remove(E o) { return false; } @Override public boolean remove(int index) { return false; } @Override public boolean contains(E o) { return false; } @Override public boolean isEmpty() { return false; } @Override public E get(int index) { return null; } @Override public int size() { return size; } @Override public int indexOf(E o) { return -1; } @Override public void clear() { } @Override public String toString() { return null; } }
public interface CollectionInterface { boolean add(E e); // appends the specified element to the end of this list. void clear(); // removes all of the elements from this list. boolean contains(E o); // returns true if this list contains the specified element. E get(int index); // returns element at the index or throws IndexOutOfBoundsException // if (index < 0 || index >= size()) int indexOf(E o); // returns the index of o in list or -1 if not found boolean isEmpty(); // returns boolean depending on the size of the list boolean remove(int index); // removes element at position index. Returns true if element was removed boolean remove(E o); // removes fist instance of o. Returns true if element was removed int size(); // returns the number of elements in the list }
Tester
import java.io.File; import java.io.IOException; import java.nio.file.Files; import java.nio.file.Paths; import java.util.ArrayList; import java.util.List; import java.util.Scanner; public class Tester { public static void main(String[] args) { LinkedCollection stuff = new LinkedCollection(); // stuff.add("A"); // stuff.add("B"); // stuff.add("C"); // stuff.add("D"); // System.out.println("Before: " + stuff); // System.out.println("remove(10); = " + stuff.remove(10)); // System.out.println("remove("C"); = " + stuff.remove("C")); // System.out.println("After : " + stuff); // for(int i = 'A'; i <= 'D'; i++) // System.out.printf("indexOf('%c') = %d ", i , stuff.indexOf(""+ (char)i)); // stuff.clear(); // System.out.println(stuff); int count = 0; try(Scanner fin = new Scanner(new File("words.txt"))) { while(fin.hasNextLine()) { String[] parts = clean(fin.nextLine()).split(" "); for(String s : parts) { count++; if(!stuff.contains(s)) stuff.add(s); } } } catch (IOException e) { e.printStackTrace(); } System.out.printf("Vocabulary Density (%d/%d): %.16f", count, stuff.size(), ((double)count/stuff.size())); } private static String clean(String line) { String ret = ""; for(char c : line.toLowerCase().toCharArray()) { if( (c >= 'a' && c <= 'z') || (c == ' ') || (c == ''') ) ret += c; } return ret; } }
txt file
It was at that moment that he learned there are certain parts of the body that you should never Nair. It's difficult to understand the lengths he'd go to remain short. There can never be too many cherries on an ice cream sundae. The quick brown fox jumps over the lazy dog. Now I need to ponder my existence and ask myself if I'm truly real He figured a few sticks of dynamite were easier than a fishing pole to catch fish. He didn't heed the warning and it had turned out surprisingly well. Her scream silenced the rowdy teenagers. Pantyhose and heels are an interesting choice of attire for the beach. They throw cabbage that turns your brain into emotional baggage. Thigh-high in the water, the fisherman's hope for dinner soon turned to despair. All you need to do is pick up the pen and begin. The tortoise jumped into the lake with dreams of becoming a sea turtle. She cried diamonds. They're playing the piano while flying in the plane. In the end, he realized he could see sound and hear words. Dan ate the clouds like cotton candy. In hopes of finding out the truth, he entered the one-room library. He looked behind the door and didn't like what he saw. He learned the hardest lesson of his life and had the scars, both physical and mental, to prove it. The clouds formed beautiful animals in the sky that eventually created a tornado to wreak havoc. The spa attendant applied the deep cleaning mask to the gentleman's back. She had that tint of craziness in her soul that made her believe she could actually make a difference. Her life in the confines of the house became her new normal. For the 216th time, he said he would quit drinking soda after this last Coke. She folded her handkerchief neatly. Fluffy pink unicorns are a popular status symbol among macho men. He was sitting in a trash can with high street class. He excelled at firing people nicely. The beach was crowded with snow leopards. Martha came to the conclusion that shake weights are a great gift for any occasion. It's not possible to convince a monkey to give you a banana by promising it infinite bananas when they die. The memory we used to share is no longer coherent. When he encountered maize for the first time, he thought it incredibly corny. Dolores wouldn't have eaten the meal if she had known what it actually was. Flesh-colored yoga pants were far worse than even he feared. Combines are no longer just for farms. Seek success, but always be prepared for random cats. He decided water-skiing on a frozen lake wasn't a good idea. He put heat on the wound to see what would grow. She was too short to see over the fence. He poured rocks in the dungeon of his mind. It doesn't sound like that will ever be on my travel list. There have been days when I wished to be separated from my body, but today wasn't one of those days. Joyce enjoyed eating pancakes with ketchup. The knives were out and she was sharpening hers. I purchased a baby clown from the Russian terrorist black market. The toy brought back fond memories of being lost in the rain forest. The urgent care center was flooded with patients after the news of a new deadly virus was made public. She moved forward only because she trusted that the ending she now was going through must be followed by a new beginning. He kept telling himself that one day it would all somehow make sense. If any cop asks you where you were, just say you were visiting Kansas. She only paints with bold colors; she does not like pastels. Yeah, I think it's a good environment for learning English. Two seats were vacant. Your girlfriend bought your favorite cookie crisp cereal but forgot to get milk. He walked into the basement with the horror movie from the night before playing in his head. There's an art to getting your way, and spitting olive pits across the table isn't it. It had been sixteen days since the zombies first attacked. The light in his life was actually a fire burning all around him. The doll spun around in circles in hopes of coming alive. He looked behind the door and didn't like what he saw. They ran around the corner to find that they had traveled back in time. Too many prisons have become early coffins. Martha came to the conclusion that shake weights are a great gift for any occasion. There were three sphered rocks congregating in a cubed room. He was so preoccupied with whether or not he could that he failed to stop to consider if he should. Never underestimate the willingness of the greedy to throw you under the bus. Don't piss in my garden and tell me you're trying to help my plants grow. The clouds formed beautiful animals in the sky that eventually created a tornado to wreak havoc. They improved dramatically once the lead singer left. She was disgusted he couldn't tell the difference between lemonade and limeade. As the asteroid hurtled toward earth, Becky was upset her dentist appointment had been canceled. If I don't like something, I'll stay away from it. As time wore on, simple dog commands turned into full paragraphs explaining why the dog couldn't do something. The stranger officiates the meal. The knives were out and she was sharpening hers. He was surprised that his immense laziness was inspirational to others. If my calculator had a history, it would be more embarrassing than my browser history. As the years pass by, we all know owners look more and more like their dogs. The irony of the situation wasn't lost on anyone in the room. The sunblock was handed to the girl before practice, but the burned skin was proof she did not apply it. There should have been a time and a place, but this wasn't it. We should play with legos at camp. She traveled because it cost the same as therapy and was a lot more enjoyable. Whenever he saw a red flag warning at the beach he grabbed his surfboard. The toy brought back fond memories of being lost in the rain forest. Charles ate the french fries knowing they would be his last meal. It's much more difficult to play tennis with a bowling ball than it is to bowl with a tennis ball. The tart lemonade quenched her thirst, but not her longing. The old apple revels in its authority. The blue parrot drove by the hitchhiking mongoose. He appeared to be confusingly perplexed. The blinking lights of the antenna tower came into focus just as I heard a loud snap. There are no heroes in a punk rock band. The sign said there was road work ahead so he decided to speed up. The rusty nail stood erect, angled at a 45-degree angle, just waiting for the perfect barefoot to come along. You're good at English when you know the difference between a man eating chicken and a man-eating chicken. She was the type of girl who wanted to live in a pink house. The small white buoys marked the location of hundreds of crab pots. She looked at the masterpiece hanging in the museum but all she could think is that her five-year-old could do better. She had that tint of craziness in her soul that made her believe she could actually make a difference. Doris enjoyed tapping her nails on the table to annoy everyone. I am my aunt's sister's daughter. There aren't enough towels in the world to stop the sewage flowing from his mouth. The lake is a long way from here. This is the last random sentence I will be writing and I am going to stop mid-sent Someone I know recently combined Maple Syrup & buttered Popcorn thinking it would taste like caramel popcorn. It didn't and they don't recommend anyone else do it either. Greetings from the galaxy MACS0647-JD, or what we call home. The bees decided to have a mutiny against their queen. Don't step on the broken glass. I'm a living furnace. He picked up trash in his spare time to dump in his neighbor's yard. This is a Japanese doll. You bite up because of your lower jaw. He went back to the video to see what had been recorded and was shocked at what he saw. He waited for the stop sign to turn to a go sign. The river stole the gods. Shingle color was not something the couple had ever talked about. Last Friday I saw a spotted striped blue worm shake hands with a legless lizard. The mysterious diary records the voice. The sign said there was road work ahead so he decided to speed up. He's in a boy band which doesn't make much sense for a snake. Today I heard something new and unmemorable. It turns out you don't need all that stuff you insisted you did. She wore green lipstick like a fashion icon. He liked to play with words in the bathtub. He looked behind the door and didn't like what he saw. Pantyhose and heels are an interesting choice of attire for the beach. I love bacon, beer, birds, and baboons. Today is the day I'll finally know what brick tastes like. He wondered if she would appreciate his toenail collection. The two walked down the slot canyon oblivious to the sound of thunder in the distance. The fish listened intently to what the frogs had to say. The knives were out and she was sharpening hers. Before he moved to the inner city, he had always believed that security complexes were psychological. Cats are good pets, for they are clean and are not noisy. She did a happy dance because all of the socks from the dryer matched. Be careful with that butter knife. Pink horses galloped across the sea. Tuesdays are free if you bring a gnome costume. No matter how beautiful the sunset, it saddened her knowing she was one day older. There should have been a time and a place, but this wasn't it. She couldn't decide of the glass was half empty or half full so she drank it. I love eating toasted cheese and tuna sandwiches. Don't piss in my garden and tell me you're trying to help my plants grow. As the years pass by, we all know owners look more and more like their dogs. There can never be too many cherries on an ice cream sundae. He was sure the Devil created red sparkly glitter. I just wanted to tell you I could see the love you have for your child by the way you look at her.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
implement the LinkedCollection class and complete the methods according to the provided interface youll need to fill in the methods with the appropria...Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started