Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Hi I am really confused about how to even write this code it is getting really h

ID: 3849959 • Letter: H

Question

Hi I am really confused about how to even write this code it is getting really hard for me and I am completely lost and would really appreciate help with a full code explained in detail about how and why you implemented certain things.

JAVA: Implement the ADT character string as the class LinkedString by using a linked list of characters. Include the following LinkedString constructors and methods:

-LinkedString(char[] value):

Allocates a new character linked list so that it represents the sequence of characters currently contained in the character array argument.

-LinkedString(String original):

Initializes a new character linked list so that it represents the same sequence of characters as the argument.

-char charAt(int index)

Returns the char value at the specified index. The first character in the linked character string is in position zero.

-LinkedString concat(LinkedString str)

Concatenates the specified linked character string to the end of this linked character string.

-boolean isEmpty()

Returns true if, and only if, length() is 0.

-int length()

Returns the length of this linked character string.

-LinkedString substring(int beginIndex, int endIndex)

Returns a new linked character string that is a substring of this linked character string.

Implement LinkedString so that it is mimics with the String class. For example, character positions should start at zero. Also, keep track of the number of characters in the string; the length should be determined without traversing the linked list and counting.

THREE SEPRATE CLASSES

1) LinkedString Class

The class which defines the LinkedString ADT. This class must implement all of the methods listed in the project specification.

2) Node Class

A class which serves as a template for the objects which make up the Linked List in the ADT LinkedString

3) Test Class

This class should contain a main() method which creates an instance of the LinkedString ADT and invokes each method you have written in the LinkedString class. This must be done to ensure that all of the LinkedString class methods work as specified.

Thank you once again I really apreciate any help to help me learn to better write my programs!

Explanation / Answer

#include <iostream.h>

#include <conio.h>

struct node

{

int data;

node *next;

};

class linklist

{

node *head;

public:

linklist()

{head=NULL;}

void create(void);

void display(void);

};

void linklist :: create(void)

{

node *newl=NULL,*end=newl;

int info;

while(1)

{

    cout<<" enter -999 to terminate ";

    cout<<"enter info:-";

    cin>>info;

     if(info==-999)

        break;

     else

     {

        newl=new node;

        newl->data=info;

        if(head==NULL)

           head=newl;

        else

           end->next=newl;

        end=newl;

        end->next=NULL;

     }

    }

}

void linklist :: display(void)

{

cout<<" Display Function ";

node *temp=head;

    while(temp!=NULL)

    {

       cout<<temp->data;

        if(temp->next!=NULL)

          cout<<"==>";

        temp=temp->next;

    }

delete(temp);

}

void main()

{

clrscr();

linklist o1;

o1.create();

o1.display();

getch();

}