A linked list of objects solution

A Linked List of Objects

The file IntList.java contains an example of a linked list of integers A list of objects is a lot like a list of integers or a particular type of object such as a Magazine, except the value stored is an Object, not an int or Magazine.

// ***************************************************************

// FILE: IntList.java

//

// Purpose: Defines a class that represents a list of integers

//

// ***************************************************************

public class IntList

{

privateIntNode front; //first node in list

//—————————————–

// Constructor. Initially list is empty.

//—————————————–

publicIntList()

{

front = null;

}

//—————————————–

// Adds given integer to front of list.

//—————————————–

public void addToFront(intval)

{

front = new IntNode(val,front);

}

//—————————————–

// Adds given integer to end of list.

//—————————————–

public void addToEnd(intval)

{

IntNodenewnode = new IntNode(val,null);

//if list is empty, this will be the only node in it

if (front == null)

front = newnode;

else

{

//make temp point to last thing in list

IntNode temp = front;

while (temp.next != null)

temp = temp.next;

//link new node into list

temp.next = newnode;

}

}

//—————————————–

// Removes the first node from the list.

// If the list is empty, does nothing.

//—————————————–

public void removeFirst()

{

if (front != null)

front = front.next;

}

//————————————————

// Prints the list elements from first to last.

//————————————————

public void print()

{

System.out.println(“——————–“);

System.out.print(“List elements: “);

IntNode temp = front;

while (temp != null)

{

System.out.print(temp.val + ” “);

temp = temp.next;

}

System.out.println(“n———————–n”);

}

 

//*************************************************************

// An inner class that represents a node in the integer list.

// The public variables are accessed by the IntList class.

//*************************************************************

private class IntNode

{

publicintval; //value stored in node

publicIntNode next; //link to next node in list

//——————————————————————

// Constructor; sets up the node given a value and IntNode reference

//——————————————————————

publicIntNode(intval, IntNode next)

{

this.val = val;

this.next = next;

}

}

}

 

Write a class ObjList that contains arbitrary objects and that has the following methods:

Place your order
(550 words)

Approximate price: $22

Calculate the price of your order

550 words
We'll send you the first draft for approval by September 11, 2018 at 10:52 AM
Total price:
$26
The price is based on these factors:
Academic level
Number of pages
Urgency
Basic features
  • Free title page and bibliography
  • Unlimited revisions
  • Plagiarism-free guarantee
  • Money-back guarantee
  • 24/7 support
On-demand options
  • Writer’s samples
  • Part-by-part delivery
  • Overnight delivery
  • Copies of used sources
  • Expert Proofreading
Paper format
  • 275 words per page
  • 12 pt Arial/Times New Roman
  • Double line spacing
  • Any citation style (APA, MLA, Chicago/Turabian, Harvard)

Our guarantees

Delivering a high-quality product at a reasonable price is not enough anymore.
That’s why we have developed 5 beneficial guarantees that will make your experience with our service enjoyable, easy, and safe.

Money-back guarantee

You have to be 100% sure of the quality of your product to give a money-back guarantee. This describes us perfectly. Make sure that this guarantee is totally transparent.

Read more

Zero-plagiarism guarantee

Each paper is composed from scratch, according to your instructions. It is then checked by our plagiarism-detection software. There is no gap where plagiarism could squeeze in.

Read more

Free-revision policy

Thanks to our free revisions, there is no way for you to be unsatisfied. We will work on your paper until you are completely happy with the result.

Read more

Privacy policy

Your email is safe, as we store it according to international data protection rules. Your bank details are secure, as we use only reliable payment systems.

Read more

Fair-cooperation guarantee

By sending us your money, you buy the service we provide. Check out our terms and conditions if you prefer business talks to be laid out in official language.

Read more