Table Class help

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • elainenguyen
    New Member
    • Oct 2006
    • 51

    Table Class help

    I am writting an address book which store name and address.
    I've written a Node class with Get and Set method of String key and String value
    I've also written a Main class for the menu to promt user input and call method from Node clasas and insert to table class.

    I am in the process of writting this table class. However, I am stuck at the the other method, can someone help?
    Here is my code:

    public class Table
    {
    //constructor
    public Table (String name, String address)
    {
    this.name=key;
    this.address=va lue;
    }
    private Node head=null;

    //Insert a new entry. If an entry already exiss with the given key value, make no inserton but return false.
    public boolean insert (String key, String value)
    {
    //insearting a new node at the beginning of the list
    Node pointer=head;
    while (pointer!=key.e quals(pointer.g etkey()))
    {
    pointer=pointer .getNext();
    }
    if (pointer=null)
    {
    Node n = new Node ();//create a node to hold string
    n.setNext(head) ;//link to head of the list
    head=n;
    }
    }

    //Look up an existing entry with the given key and returns the associated value. If no entry is found null is returned
    public String lookUp (String key)
    {
    Node pointer=head;
    while ((pointer !=null && !key.equals(poi nter.getkey())) )
    {
    pointer=pointer .getNext();
    }
    //name was found or not found.
    if (pointer!=null)
    return pointer.getvalu e();
    else
    return null;
    }
    }

    //Delete an existing entry with the given key. If no entry is found returns false.
    public boolean delete (String key)
    {


    }

    //update an existing entry. Update the old value with the new value associated with the given key
    public boolean update (String key, String newValue)
    {

    }

    //Set mark to the first entry of the table, return false when table is empty
    public boolean markToStart()
    {

    }

    //move mark to the next item in the table. If there is no next item, return false
    public boolean advanceMark()
    {

    }

    //returns the key stored in the item at the current mark
    public String keyAtMark()
    {

    }

    //returns the value in the item at the current mark
    public String valueAtMark()
    {

    }

    Thanks!
Working...