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 5 of 5

Thread: Help wih implementation...

  1. #1
    Junior Member
    Join Date
    Nov 2009
    Posts
    3
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default Help wih implementation...

    }

    How can I implement this interface to somthing like Node2.java ?

    /**
     * An interface for a Node, which is a holder object storing a
     * single element.
     */
    public interface Node<V>
    {
    	/** Return the element stored at this Node. */
    	public V element();
     
    	/** Replaces the element stored at this Node by a new element */
    	public void replaceElement(V o);
     
    	/** Gives an id to this Position. There is no requirement for its value.
    	 *  It is just provided for your convinience.
    	 *  However in the graphs we use for testing you may assume each number
    	 *  is only used once, and all id are in the range [0,graph.numVertices()-1].
    	 *  No part of the testing program calls this method.
    	 */
    	public int id();
     
    	/** This is also just for your convinience.
    	 *  You may assume no that no part of the testing program calls this method.
    	 */
    	public void setId(int id);
     
    	/** Two Nodes are considered equal if they hold equal elements */
    	public boolean equals(Node<V> p);
     
    	/** remember to implement a toString() */
    	public String toString();
    Last edited by Freaky Chris; November 23rd, 2009 at 11:10 AM.


  2. #2
    Super Moderator Json's Avatar
    Join Date
    Jul 2009
    Location
    Warrington, United Kingdom
    Posts
    1,274
    My Mood
    Happy
    Thanks
    70
    Thanked 156 Times in 152 Posts

    Default Re: Help wih implementation...

    Is this some sort of assignment?

    // Json

  3. #3
    Junior Member
    Join Date
    Nov 2009
    Posts
    3
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default Re: Help wih implementation...

    Just some excersize I`m doing before my exam

  4. #4
    Super Moderator Json's Avatar
    Join Date
    Jul 2009
    Location
    Warrington, United Kingdom
    Posts
    1,274
    My Mood
    Happy
    Thanks
    70
    Thanked 156 Times in 152 Posts

    Default Re: Help wih implementation...

    Ok here we go

    public class StringNode implements Node<String>
    {
            private String element;
     
            private int id;
     
    	/** Return the element stored at this Node. */
    	public String element() {
                return this.element;
            }
     
    	/** Replaces the element stored at this Node by a new element */
    	public void replaceElement(String o) {
                this.element = o;
            }
     
    	/** Gives an id to this Position. There is no requirement for its value.
    	 *  It is just provided for your convinience.
    	 *  However in the graphs we use for testing you may assume each number
    	 *  is only used once, and all id are in the range [0,graph.numVertices()-1].
    	 *  No part of the testing program calls this method.
    	 */
    	public int id() {
                 return this.id;
            }
     
    	/** This is also just for your convinience.
    	 *  You may assume no that no part of the testing program calls this method.
    	 */
    	public void setId(int id) {
                 this.id = id;
            }
     
    	/** Two Nodes are considered equal if they hold equal elements */
    	public boolean equals(Node<String> p) {
     
            }
     
    	/** remember to implement a toString() */
    	public String toString() {
                return "StringNode(" + this.id + ", " + this.element + ")";
            }
    }

    I might have missed something but thats pretty much it

    // Json

  5. The Following User Says Thank You to Json For This Useful Post:

    Frank_nor (November 24th, 2009)

  6. #5
    Junior Member
    Join Date
    Nov 2009
    Posts
    3
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default Re: Help wih implementation...

    Thanks a lot. I got it.

Similar Threads

  1. B+ Tree implementation
    By programmer in forum Java Theory & Questions
    Replies: 2
    Last Post: November 15th, 2009, 05:47 PM
  2. Binary Search Tree implementation
    By Ceasar in forum Java Theory & Questions
    Replies: 3
    Last Post: October 9th, 2009, 12:23 AM