In: Computer Science
Using Java, write code as follows:
Create the appropriate accessors and mutators for both variables.
When a ListOfItems is created, create a new Node and set both the head and the tail to refer to it. The first time that the “add” method is called, add the Object to the head node and increment size from 0 to 1 Each time add is called after that, follow this algorithm:
Also provide an implementation for the get method. This will require you to start at the head and use the getNext method to count the appropriate number of nodes in the list before returning the item at the specified index using its getItem method.
import java.io.*;
import java.util;
public class void main {
interface Items { public void method1(); }
int add()
{
public void add( Object item )
public Object get( int index )
public int size(add)
public static void main(String[] args)
public void addAll( Object[] items ) // done for looping //
public String toString()
{
int
arr[] =
new
int
[] { "abc"
, 1
,
2
, 0
};
Vector<Integer>
v =
new
Vector();
Hashtable<Integer,
String> m =
new
Hashtable();
}
public class MyClass { int x; public MyClass()
{
x = 55;
}
public static void main(String[] args)
{
MyClass myObj = new MyClass(); //constructor
//
System.out.println(myObj.x);
}
}
class node
{
object item =new item()
class Node{
int data;
Node next;
sessionItem.setItem(keyname, value)
class Item LinkNode;
}
}
public static void testItems(Items)
{
public class Calculator { public static int add(int number8, int number9) { return number8 + number9; } public static int sub(int number1, int number2) { return number1 - number2; }
}
}