Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 4 of 4

Thread: Help with linked list

  1. #1
    Junior Member
    Join Date
    Nov 2010
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Help with linked list

    I hope I put this in the right section as I am new to this forum. I am currently in a java programing class that I am taking online and our homework assignment is to create a linked list and I honestly do not know where to start as I have never worked with this before.

    The assignment is: Create a class that tracks the name and score of the top 10 gamers using a linked list. Duplicate entries are allowed in the list. However, only the top 10 scores will be maintained. When the list contains 10 entries and a new entry is attempted, the application should only add the new entry if the score exceeds the lowest score on the list. In that case, the lowest score currently on the list should be dropped to make room for the new entry.

    I think I am just drawing a blank and need help getting started. I appreciate any help you have to offer. Thanks.


  2. #2
    Junior Member
    Join Date
    Sep 2010
    Posts
    16
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default Re: Help with linked list

    hi joe,

    well firstly if i was you i would start getting into the habit of writing down what your problem is:

    atm you need to do:

    1. Create a class that tracks the name and score of the top 10 gamers using a linked list.
    2. Only the top 10 scores will be maintained.
    3. New entry should only be add if the score exceeds the lowest score on the list. In that case, the lowest score currently on the list should be dropped to make room for the new entry.

    Now you have a clear agenda. first thing you need to do is make a new Class maybe call it scores, in that class have 2 attributes Name and Score and create some getters and setters.

    Then when your create a Linkedlist i.e LinkedList <Scores> ScoreList = new LinkedList<Scores>();
    from there you just need to do some constraints so you only have 10 scores in the list etc and then your done

  3. #3
    mmm.. coffee JavaPF's Avatar
    Join Date
    May 2008
    Location
    United Kingdom
    Posts
    3,336
    My Mood
    Mellow
    Thanks
    258
    Thanked 287 Times in 225 Posts
    Blog Entries
    4

    Default Re: Help with linked list

    Welcome to the forums.

    Here is a linkedlist example:

    import java.util.LinkedList;
     
    public class SimpleJavaLinkedListExample {
     
    	public static void main(String[] args) {
     
    		// create LinkedList object
    		LinkedList lList = new LinkedList();
    		// add elements to LinkedList
    		lList.add("1");
    		lList.add("2");
    		lList.add("3");
    		lList.add("4");
    		lList.add("5");
     
    		/*
    		 * 
    		 * Please note that primitive values can not be added into LinkedList
    		 * 
    		 * directly. They must be converted to their corrosponding wrapper
    		 * class.
    		 */
     
    		System.out.println("LinkedList contains : " + lList);
     
    	}
     
    }

     

    LinkedList contains : [1, 2, 3, 4, 5]


    Please use [highlight=Java] code [/highlight] tags when posting your code.
    Forum Tip: Add to peoples reputation by clicking the button on their useful posts.

    Looking for a Java job? Visit - Java Programming Careers

  4. #4
    mmm.. coffee JavaPF's Avatar
    Join Date
    May 2008
    Location
    United Kingdom
    Posts
    3,336
    My Mood
    Mellow
    Thanks
    258
    Thanked 287 Times in 225 Posts
    Blog Entries
    4

    Default Re: Help with linked list

    Thread moved to - Collections and Generics - Java Programming Forums
    Please use [highlight=Java] code [/highlight] tags when posting your code.
    Forum Tip: Add to peoples reputation by clicking the button on their useful posts.

    Looking for a Java job? Visit - Java Programming Careers

Similar Threads

  1. Generic Doubly Linked List
    By javapenguin in forum What's Wrong With My Code?
    Replies: 23
    Last Post: October 23rd, 2010, 03:13 PM
  2. [SOLVED] Update on Doubly Linked List
    By javapenguin in forum What's Wrong With My Code?
    Replies: 2
    Last Post: October 11th, 2010, 07:19 PM
  3. Simple linked list
    By Koren3 in forum Collections and Generics
    Replies: 10
    Last Post: November 2nd, 2009, 02:33 AM
  4. circular linked list
    By student123xyz in forum Collections and Generics
    Replies: 4
    Last Post: August 19th, 2009, 10:40 AM
  5. Recursive function based on Linked list
    By rosh72851 in forum Collections and Generics
    Replies: 1
    Last Post: March 9th, 2009, 06:23 PM

Tags for this Thread