Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I wrote some code for this problem, but I can't seem to figure it out. Can someone help? _______________________________________________________________________________________________________________ Main Class: import java.util.*; import static

I wrote some code for this problem, but I can't seem to figure it out. Can someone help?

_______________________________________________________________________________________________________________

Main Class:

import java.util.*;

import static java.lang.System.*;

public class Main

{

public static void main(String[] args)

{

//A A A A B V S E A S A A

HistoList test = new HistoList();

test.addLetter('A');

test.addLetter('A');

test.addLetter('A');

test.addLetter('A');

test.addLetter('B');

test.addLetter('V');

test.addLetter('S');

test.addLetter('E');

test.addLetter('A');

test.addLetter('S');

test.addLetter('A');

test.addLetter('A');

System.out.println(test);

//A B C

test = new HistoList();

test.addLetter('A');

test.addLetter('B');

test.addLetter('C');

System.out.println(test);

//A B C A B C A B C A B C A B C

test = new HistoList();

test.addLetter('A');

test.addLetter('B');

test.addLetter('C');

test.addLetter('A');

test.addLetter('B');

test.addLetter('C');

test.addLetter('A');

test.addLetter('B');

test.addLetter('C');

test.addLetter('A');

test.addLetter('B');

test.addLetter('C');

test.addLetter('A');

test.addLetter('B');

test.addLetter('C');

System.out.println(test);

}

}

__________________________________________________________________________________________________________________

HistoList Class:

import java.util.*;

import static java.lang.System.*;

public class HistoList

{

private HistoNode front;

public HistoList( )

{

front = null;

}

//addLetter will add a new node to

//the front for let if let does not exist

//addLetter will bump up the count if let already exists

public void addLetter(char let)

{

}

//returns the index pos of let in the list if let exists

public int indexOf(char let)

{

return -1;

}

//returns a reference to the node at spot

private HistoNode nodeAt(int spot)

{

HistoNode current=null;

return current;

}

//returns a string will all values from list

public String toString()

{

String output = "";

return output;

}

}

__________________________________________________________________________________________________________________

HistoNode Class:

public class HistoNode

{

private char letter;

private int letterCount;

private HistoNode next;

public HistoNode(char let, int cnt, HistoNode n)

{

letter=let;

letterCount=cnt;

next=n;

}

public char getLetter()

{

return letter;

}

public int getLetterCount()

{

return letterCount;

}

public HistoNode getNext()

{

return next;

}

public void setLetter(char let)

{

letter=let;

}

public void setLetterCount(int cnt)

{

letterCount=cnt;

}

public void setNext(HistoNode n)

{

next = n;

}

}

__________________________________________________________________________________________________________________

Instructions:

image text in transcribed

Lab Goal : This lab was designed to teach you more about a linked list and how to use a linked list to create a data structure. Lab Description : Write a program that uses nodes to store letters and letter counts. The data structure created for this program is like a Map. Each node will store a character, a count of how many of those characters have occurred, and a reference to the next node in the list. Each character with its count will occur at most once in the list. HistoNode - stores a letter, the letter's count, and the next node Required Files public class HistoNode 1 private char letter; private int letterCount; private HistoNode next; EXTENSION : public HistoNode (char let, int cnt, HistoNode n) letter-let: letterCount=cnt; next=n; 1 Add in a remove method that will remove a letter. If there is more than one of the letter, the count is decreased by one. If there is only 1 of the letter, then that node is removed. public char getLetter() return letter: 1 public int getLetterCount() return letterCount; } public void setLetter (char let) letter-let; 1 public void setLetterCount(int cnt) letterCount ont; 1 public void setNext (HistoNoden) next = n; } 1 Sample Data : A A A AB VSE AS A A ABC ABC ABC ABC ABC ABC

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored 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

Recommended Textbook for

Strategic Database Technology Management For The Year 2000

Authors: Alan Simon

1st Edition

155860264X, 978-1558602649

More Books

Students also viewed these Databases questions

Question

Describe how firms can properly prepare for growth.

Answered: 1 week ago