subject

Can someone URGENTLY help me with my java code (I WILL GIVE BRAINLIEST)!? Ive been working on it for hours and its not working! *examples of required output at the bottom*

code: public class CircularList
{
private ListNode head;
private ListNode tail;
private int size;

public CircularList()

{

head = tail = null;

size = 0;

}

public int size()

{

return size;

}

public boolean isEmpty()

{

return (size == 0);

}

public int first()

{

if (head != null) {

return head. getValue();

}

return -1;

}

public Integer last()

{

if (tail != null) {

return tail. getValue();

}

return -1;

}

public void addFirst(Integer value)

{

head = new ListNode(value, head);

if (tail == null) {

tail = head;

}

size++;

}

public void addLast(Integer value)

{

ListNode newTail = new ListNode(value, null);

if (tail != null) {

tail. setNext(newTail);

tail = newTail;

} else {

head = tail = newTail;

}

size++;

}

public void addAtPos(int pos, Integer value)

{

if (pos == 0) {

addFirst(value);

return;

}

if (pos <= 0 || pos > size) {

return;

}

if (pos == size) {

addLast(value);

return;

}

ListNode ptr = head;

for(int i=0; i = size) {

return retVal;

}

if (pos == 0) {

return removeFirst();

}

ListNode ptr = head;

for(int i=0; i
ptr = ptr. getNext();

}

retVal = ptr. getNext().getValue();

if (pos == size-1) {

tail = ptr;

tail. setNext(null);

} else {

ptr. setNext(ptr. getNext().getNext());

}

size--;

return retVal;

}

public int findNode(Integer find)

{

ListNode ptr = head;

for(int pos=0; pos
if (ptr. getValue() == find) {

return pos;

}

ptr = ptr. getNext();

}

return -1;

}

public void rotate()

{

addLast(removeFirst());

}

public String toString()

{

String output = "";

ListNode iter = head;

while(iter != null) {

output += String. format("%d ", iter. getValue());

iter = iter. getNext();

}

return output;

}

}

size = 6 first = 50 last = 60
50 20 10 40 30 60

removeFirst = 50
size = 5 first = 20 last = 60
20 10 40 30 60

removed = 30
size = 4 first = 20 last = 60
20 10 40 60

size = 4 first = 20 last = 60
20 10 40 60

found at -1
removed = -1
size = 4 first = 20 last = 60
20 10 40 60

size = 4 first = 10 last = 20
10 40 60 20

ansver
Answers: 1

Another question on Computers and Technology

question
Computers and Technology, 22.06.2019 06:00
The width of a piece of rectangular land is 5m shorter rhan 1/3 of its length .find the width of the land if the length is 60m,150m.
Answers: 1
question
Computers and Technology, 22.06.2019 14:30
What percentage of companies is projected to use social media to locate new employees in 2012
Answers: 2
question
Computers and Technology, 22.06.2019 18:40
Mariah was working on a multimedia presentation that included both video and audio files. the file was huge, and she wanted to send it to her coworker in another office. she needed to reduce the size of the file so that it could be transmitted faster. the utility she used to do this was
Answers: 2
question
Computers and Technology, 23.06.2019 20:40
Instruction active describing list features which statements accurately describe the features of word that are used to create lists? check all that apply. the tab key can be used to create a sublist. the enter key can be used to add an item to a list. the numbering feature allows for the use of letters in a list. the numbering feature can change the numbers to bullets in a list. the multilevel list feature provides options for different levels in a list.
Answers: 2
You know the right answer?
Can someone URGENTLY help me with my java code (I WILL GIVE BRAINLIEST)!? Ive been working on it for...
Questions
question
Mathematics, 23.07.2021 14:00
Questions on the website: 13722361