954,500 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Dictionary Program. help!!

hi guys.. can you help me with my assignment?

my proff told me to make a dictionary prog that can do the following..

1. Add new word and definition
2.delete word and its definition
3. view all words and its definition
4. Update word and its definition
5. Search a word.

this is what i have started guys..

but i still don't how to make this work.. its so messy :(

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace LinkedList
{
    class Program
    {
        static void Main(string[] args)
        {
            {
                SingleLinkedList list = new SingleLinkedList();
                string what;
                Console.WriteLine("Press U to Update, I to insert, D to Delete and S to search a word: ");
                what = Convert.ToString(Console.ReadLine());
                if (what == "I")
                {
                    //int data = 0;
                    string input, meaning, property;
                    Console.WriteLine("Insert Word: ");
                    input = Convert.ToString(Console.ReadLine());
                    Console.WriteLine("Meaning: ");
                    meaning = Convert.ToString(Console.ReadLine());
                    Console.WriteLine("Property: ");
                    property = Convert.ToString(Console.ReadLine());
                    Console.WriteLine(input + "- " + " [" + property + "], " + meaning);

                }

                else
                    if (what == "S")
                    {
                        Console.WriteLine("Search Word");

                    }
                    else
                        if (what == "U")
                        {
                            Console.WriteLine("Search Word:");
                        }
                        else
                            if (what == "D")
                            {
                                Console.WriteLine("Delete Word: ");






                            } Console.ReadKey();
            }
        }
    }
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace LinkedList
{
    class Node
 {
        private Node _next;
        private object _data;

        public Node()
        {
            _next = null;
        }
        public Node next
        {
            get
            {
                return _next;
            }
            set 
            {
                _next = value;
            }
        }
        public object data
        {
            get
            {
                return _data;
            }
            set
            {
                _data = value;
            }
        }
    }
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace LinkedList
{
    class SingleLinkedList
    {
        public Node head;
        public Node tracer;

        public SingleLinkedList()
        {
            head = null;
            tracer = null;
        }
        public void insertNode(object data)
        {
            if (head == null)
            {
                head = new Node();
                tracer = head;
                head.data = data;
            }
            else
            {
                Node tempNode = new Node();
                tempNode.data = data;
                head.data = tempNode;
            }
        }
        public void deleteNode(object data)
        {
            Node temp;
            temp = head;

            if(head.data.ToString() == data.ToString())
            {
                head = head.next;
                temp = head;
            }
            else{
                while(temp != null && temp.next != null)
                {
                    temp.next = temp.next.next;
                    if(temp.next == null)
                    {
                        tracer = temp;
                    }
                    temp = temp.next;
                }
            }
        }
        public void traverse()
        {
            Node temp = head;
            //ArrayList list = new ArrayList();
            //object[] tempData;
            while(temp !=null)
            {
                //list.Add(temp.data);
                Console.Write(temp.data + " ");
                temp = temp.next;
            }
            //tempData = list.ToArray();
            //return tempData;
        }
    }
}


it runs but its a mess. hehe..

some are leaved blank guys.. i dont know what to do.. and i donot know how to store :(

wil0022
Newbie Poster
24 posts since Aug 2009
Reputation Points: 10
Solved Threads: 0
 

Is there a reason you have used a SingleLinkedList?
I personally would have gone for something more strongly typed:

//private collection that you can add/update/remove
private List<DictionaryEntry> _dictionary;

//class to store each entry with public properties to access values
    public class DictionaryEntry
    {
    
        private string _word;
        private string _description;

        public DictionaryEntry()
        {
            _word = string.Empty;
            _desc = string.Empty;
        }
        public string Word
        {
            get { return _word; }
            set { _word = value; }
        }
        public string Description
        {
            get { return _description; }
            set { _description = value; }
        }
    
    }


Linked Lists are usually used to store data where the order is important such as stacks/queues/etc.
I dont see a reason to maintain links between your dictionary items so a List is a better way to go :)

Ryshad
Nearly a Posting Virtuoso
1,307 posts since Aug 2009
Reputation Points: 512
Solved Threads: 246
 

so it means... the LinkedList it no use at all? thanks..

btw, can you teach me how to store data?

cuz i think using

variable = Convert.ToString(Console.ReadLine());

wont work..

wil0022
Newbie Poster
24 posts since Aug 2009
Reputation Points: 10
Solved Threads: 0
 

i have edited the linked list sir.. i will post it after i have finished debugging it.

wil0022
Newbie Poster
24 posts since Aug 2009
Reputation Points: 10
Solved Threads: 0
 
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace LinkedList
{
    class SingleLinkedList
    {
        public Node head;
        public Node tracer;

        public SingleLinkedList()
        {
            head = null;
            tracer = null;
        }
        public void insertNode(string word, string meaning, string property)
        {
            if (head == null)
            {
                head = new Node();
                tracer = head;

                head.word = word;
                head.meaning = meaning;
                head.property = property;
            }
            else
            {
                Node tempNode = new Node();

                tempNode.word = word;
                tempNode.meaning = meaning;
                tempNode.property = property;
                tracer.next = tempNode;
                tracer = tempNode;

            }
        }
        public void deleteNode(string word)
        {
            Node temp;
            temp = head;

            if (head.word.ToString() == word.ToString())
            {
                head = head.next;
                temp = head;
            }
            else
            {
                while (temp != null && temp.next != null)
                {
                    temp.next = temp.next.next;
                    if (temp.next == null)
                    {
                        tracer = temp;
                    }
                    temp = temp.next;
                }
            }
        }
        public void traverse()
        {
            Node temp = head;
            //ArrayList list = new ArrayList();
            //object[] tempData;
            while (temp != null)
            {
                //list.Add(temp.data);
                Console.Write(temp.word + " \n");
                Console.Write(temp.meaning + " \n");
                Console.Write(temp.property + " \n");
                temp = temp.next;
            }
            //tempData = list.ToArray();
            //return tempData;
        }

        public void searchNode(string word)
        {
            Node temp;
            temp = head;
            if (head.word.ToString() == word.ToString())
            {
                Console.WriteLine(head.word.ToString());
                Console.WriteLine(head.meaning.ToString());
                Console.WriteLine(head.property.ToString());
            }
            else
            {
                while (temp != null && temp.next != null)
                {
                    if (temp.next.word.ToString() == word.ToString())
                    {
                        Console.WriteLine(temp.word.ToString());
                        Console.WriteLine(temp.meaning.ToString());
                        Console.WriteLine(temp.property.ToString());

                        if (temp.next == null)
                        {
                            tracer = temp;
                            break;
                        }
                    }
                    temp = temp.next;
                }
            }
        }
        public void updateNode(string word)
        {
            Node temp;
            temp = head;

            if (head.word.ToString() == head.ToString())
            {
                Console.Write("Word: ");
                head.word = Console.ReadLine();

                Console.Write("Meaning: ");
                head.meaning = Console.ReadLine();

                Console.Write("Property: ");
                head.property = Console.ReadLine();
            }
            else
            {
                while (temp != null && temp.next != null)
                {
                    if (temp.next.word.ToString() == word.ToString())
                    {
                        Console.Write("Word: ");
                        temp.word = Console.ReadLine();

                        Console.Write("Meaning: ");
                        temp.meaning = Console.ReadLine();

                        Console.Write("Property: ");
                        temp.property = Console.ReadLine();
                    }
                    else
                    {
                        while (temp != null && temp.next != null)
                        {
                            if (temp.next.word.ToString() == word.ToString())
                            {
                                Console.Write("Word: ");
                                temp.word = Console.ReadLine();

                                Console.WriteLine("Meaning: ");
                                temp.meaning = Console.ReadLine();

                                Console.WriteLine("Property: ");
                                temp.meaning = Console.ReadLine();

                                if (temp.next == null)
                                {
                                    tracer = temp;
                                    break;
                                }
                            }
                            else
                            {
                                Console.WriteLine("Word not Found");
                            }
                            temp = temp.next;
                        }
                    }
                }
            }
        }
    }
}


this is my progress.. :D

wil0022
Newbie Poster
24 posts since Aug 2009
Reputation Points: 10
Solved Threads: 0
 

sir... if i try to search the word or view all the words.. help..

here is my code sir..
my nearly finished code..

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace LinkedList
{
    class Program
    {
        static void Main(string[] args)
        {
            {
            
                SingleLinkedList list = new SingleLinkedList();
              string balik;
                do
                {
               
            
             
                string choice, meaning, property, word, update, search;
                
               
                Console.WriteLine("\n\n\t\tU - to Update a word and its meaning");
                Console.WriteLine("\t\tI - to Insert a word");
                Console.WriteLine("\t\tS - Search a word and its meaning");
                Console.WriteLine("\t\tV - View all the words in the Dictionary");
                Console.WriteLine("\t\tD - Delete a word and its meaning\n\n");
                Console.WriteLine("Enter Your Choice: ");
                choice = Convert.ToString(Console.ReadLine());
                if (choice == "I")
                {
                    //int data = 0;
                   
                    Console.WriteLine("Insert Word: ");
                    word = Console.ReadLine();

                    Console.WriteLine("Meaning: ");
                    meaning = Convert.ToString(Console.ReadLine());

                    Console.WriteLine("Property: ");
                    property = Convert.ToString(Console.ReadLine());

                    Console.WriteLine("\n"+ word + " - " + " [" + property + "], " + meaning);
                }
                else
                    if (choice == "S")
                    {
                        Console.Write("Search Word: ");
                        search = Console.ReadLine();
                        list.searchNode(search);


                    }
                    else
                        if (choice == "U")
                        {
                            Console.Write("Enter the word: ");
                            update = Console.ReadLine();
                            list.updateNode(update);


                        }
                        else
                            if (choice == "D")
                            {
                                Console.WriteLine("Delete Word: ");
                                word = Console.ReadLine();
                                list.deleteNode(word);
                            }
                            else
                                if (choice == "V")
                                {
                                    Console.WriteLine("View all dictionary words");
                                    list.traverse();
                                }
                  Console.WriteLine("\n\nGusto mo, liwat? [huo ay!/nevah!");
                    balik = Console.ReadLine();
                }
                while(balik == "huo ay!");
              

            } 

               
        }
    }
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace LinkedList
{
    class Node
 {
        private Node _next;
        private string _word;
        private string _meaning;
        private string _property;

        public Node()
        {
            _next = null;
        }
        public Node next
        {
            get
            {
                return _next;
            }
            set 
            {
                _next = value;
            }
        }
        public string word
        {
            get
            {
                return _word;
            }
            set
            {
                _word = value;
            }
        }

            public string meaning
            {
                get
                {
                    return _meaning;
                }
                set
                {
                    _meaning = value;
                }
            }
        public string property
        {
            get
            {
                return _property;
            }
            set
            {
                _property = value;



            }
        }
    }
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace LinkedList
{
    class SingleLinkedList
    {
        public Node head;
        public Node tracer;

        public SingleLinkedList()
        {
            head = null;
            tracer = null;
        }
        public void insertNode(string word, string meaning, string property)
        {
            if (head == null)
            {
                head = new Node();
                tracer = head;

                head.word = word;
                head.meaning = meaning;
                head.property = property;
            }
            else
            {
                Node tempNode = new Node();

                tempNode.word = word;
                tempNode.meaning = meaning;
                tempNode.property = property;
                tracer.next = tempNode;
                tracer = tempNode;

            }
        }
        public void deleteNode(string word)
        {
            Node temp;
            temp = head;

            if (head.word.ToString() == word.ToString())
            {
                head = head.next;
                temp = head;
            }
            else
            {
                while (temp != null && temp.next != null)
                {
                    temp.next = temp.next.next;
                    if (temp.next == null)
                    {
                        tracer = temp;
                    }
                    temp = temp.next;
                }
            }
        }
        public void traverse()
        {
            Node temp = head;
            //ArrayList list = new ArrayList();
            //object[] tempData;
            while (temp != null)
            {
                //list.Add(temp.data);
                Console.Write(temp.word + " \n");
                Console.Write(temp.meaning + " \n");
                Console.Write(temp.property + " \n");
                temp = temp.next;
            }
            //tempData = list.ToArray();
            //return tempData;
        }

        public void searchNode(string word)
        {
            Node temp;
            temp = head;
            if (head.word.ToString() == word.ToString())
            {
                Console.WriteLine(head.word.ToString());
                Console.WriteLine(head.meaning.ToString());
                Console.WriteLine(head.property.ToString());
            }
            else
            {
                while (temp != null && temp.next != null)
                {
                    if (temp.next.word.ToString() == word.ToString())
                    {
                        Console.WriteLine(temp.word.ToString());
                        Console.WriteLine(temp.meaning.ToString());
                        Console.WriteLine(temp.property.ToString());

                        if (temp.next == null)
                        {
                            tracer = temp;
                            break;
                        }
                    }
                    temp = temp.next;
                }
            }
        }
        public void updateNode(string word)
        {
            Node temp;
            temp = head;

            if (head.word.ToString() == head.ToString())
            {
                Console.Write("Word: ");
                head.word = Console.ReadLine();

                Console.Write("Meaning: ");
                head.meaning = Console.ReadLine();

                Console.Write("Property: ");
                head.property = Console.ReadLine();
            }
            else
            {
                while (temp != null && temp.next != null)
                {
                    if (temp.next.word.ToString() == word.ToString())
                    {
                        Console.Write("Word: ");
                        temp.word = Console.ReadLine();

                        Console.Write("Meaning: ");
                        temp.meaning = Console.ReadLine();

                        Console.Write("Property: ");
                        temp.property = Console.ReadLine();
                    }
                    else
                    {
                        while (temp != null && temp.next != null)
                        {
                            if (temp.next.word.ToString() == word.ToString())
                            {
                                Console.Write("Word: ");
                                temp.word = Console.ReadLine();

                                Console.WriteLine("Meaning: ");
                                temp.meaning = Console.ReadLine();

                                Console.WriteLine("Property: ");
                                temp.meaning = Console.ReadLine();

                                if (temp.next == null)
                                {
                                    tracer = temp;
                                    break;
                                }
                            }
                            else
                            {
                                Console.WriteLine("Word not Found");
                            }
                            temp = temp.next;
                        }
                    }
                }
            }
        }
    }
}
wil0022
Newbie Poster
24 posts since Aug 2009
Reputation Points: 10
Solved Threads: 0
 

get it sir.. the only problem now is update.. hehe.. help!! :)

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace LinkedList
{
    class Program
    {
        static void Main(string[] args)
        {
            {
            
                SingleLinkedList list = new SingleLinkedList();
              string balik;
                do
                {
               
            
             
                string choice, meaning, property, word, update, search;
                
               
                Console.WriteLine("\n\n\t\tU - to Update a word and its meaning");
                Console.WriteLine("\t\tI - to Insert a word");
                Console.WriteLine("\t\tS - Search a word and its meaning");
                Console.WriteLine("\t\tV - View all the words in the Dictionary");
                Console.WriteLine("\t\tD - Delete a word and its meaning\n\n");
                Console.WriteLine("Enter Your Choice: ");
                choice = Convert.ToString(Console.ReadLine());
                if (choice == "I")
                {
                    //int data = 0;
                   
                    Console.WriteLine("Insert Word: ");
                    word = Console.ReadLine();

                    Console.WriteLine("Meaning: ");
                    meaning = Convert.ToString(Console.ReadLine());

                    Console.WriteLine("Property: ");
                    property = Convert.ToString(Console.ReadLine());

                    list.insertNode(word, meaning, property);
                    Console.WriteLine("\n"+ word + " - " + " [" + property + "], " + meaning);
                }
                else
                    if (choice == "S")
                    {
                        Console.Write("Search Word: ");
                        search = Console.ReadLine();
                        list.searchNode(search);


                    }
                    else
                        if (choice == "U")
                        {
                            Console.Write("Enter the word: ");
                            update = Console.ReadLine();
                            list.updateNode(update);


                        }
                        else
                            if (choice == "D")
                            {
                                Console.WriteLine("Delete Word: ");
                                word = Console.ReadLine();
                                list.deleteNode(word);
                            }
                            else
                                if (choice == "V")
                                {
                                    Console.WriteLine("Dictionary: Word and Meaning");
                                    list.traverse();
                                }
                  Console.WriteLine("\n\nGusto mo, liwat? [y/nevah!");
                    balik = Console.ReadLine();
                }
                while(balik == "y");
              

            } 

               
        }
    }
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace LinkedList
{
    class Node
 {
        private Node _next;
        private string _word;
        private string _meaning;
        private string _property;

        public Node()
        {
            _next = null;
        }
        public Node next
        {
            get
            {
                return _next;
            }
            set 
            {
                _next = value;
            }
        }
        public string word
        {
            get
            {
                return _word;
            }
            set
            {
                _word = value;
            }
        }

            public string meaning
            {
                get
                {
                    return _meaning;
                }
                set
                {
                    _meaning = value;
                }
            }
        public string property
        {
            get
            {
                return _property;
            }
            set
            {
                _property = value;



            }
        }
    }
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace LinkedList
{
    class SingleLinkedList
    {
        public Node head;
        public Node tracer;

        public SingleLinkedList()
        {
            head = null;
            tracer = null;
        }
        public void insertNode(string word, string meaning, string property)
        {
            if (head == null)
            {
                head = new Node();
                tracer = head;
                head.word = word;
                head.meaning = meaning;
                head.property = property;
            }
            else
            {
                Node tempNode = new Node();
                tempNode.word = word;
                tempNode.meaning = meaning;
                tempNode.property = property;
                tracer.next = tempNode;
                tracer = tempNode;

            }
        }
        public void deleteNode(string word)
        {
            Node temp;
            temp = head;

            if (head.word.ToString() == word.ToString())
            {
                head = head.next;
                temp = head;
            }
            else
            {
                while (temp != null && temp.next != null)
                {
                    temp.next = temp.next.next;
                    if (temp.next == null)
                    {
                        tracer = temp;
                    }
                    temp = temp.next;
                }
            }
        }
        public void traverse()
        {
            Node temp = head;
            while (temp != null)
            {
              
                Console.WriteLine(temp.word + " - " + "[" +temp.property + "], " + temp.meaning );
             
                temp = temp.next;
            }
         
        }

        public void searchNode(string word)
        {
            Node temp;
            temp = head;
            if (head.word.ToString() == word.ToString())
            {
                Console.WriteLine(head.word.ToString() + " - " + "[" + head.property.ToString() + "], " + head.meaning.ToString());
               
            }
            else
            {
                while (temp != null && temp.next != null)
                {
                    if (temp.next.word.ToString() == word.ToString())
                    {
                        Console.WriteLine(temp.word.ToString());
                        Console.WriteLine(temp.meaning.ToString());
                        Console.WriteLine(temp.property.ToString());

                        if (temp.next == null)
                        {
                            tracer = temp;
                            break;
                        }
                    }
                    temp = temp.next;
                }
            }
        }
        public void updateNode(string word)
        {
            Node temp;
            temp = head;

            if (head.word.ToString() == head.ToString())
            {
                Console.Write("Word: ");
                head.word = Console.ReadLine();

                Console.Write("Meaning: ");
                head.meaning = Console.ReadLine();

                Console.Write("Property: ");
                head.property = Console.ReadLine();
            }
            else
            {
                while (temp != null && temp.next != null)
                {
                    if (temp.next.word.ToString() == word.ToString())
                    {
                        Console.Write("Word: ");
                        temp.word = Console.ReadLine();

                        Console.Write("Meaning: ");
                        temp.meaning = Console.ReadLine();

                        Console.Write("Property: ");
                        temp.property = Console.ReadLine();
                    }
                    else
                    {
                        while (temp != null && temp.next != null)
                        {
                            if (temp.next.word.ToString() == word.ToString())
                            {
                                Console.Write("Word: ");
                                temp.word = Console.ReadLine();

                                Console.WriteLine("Meaning: ");
                                temp.meaning = Console.ReadLine();

                                Console.WriteLine("Property: ");
                                temp.meaning = Console.ReadLine();

                                if (temp.next == null)
                                {
                                    tracer = temp;
                                    break;
                                }
                            }
                            else
                            {
                                Console.WriteLine("Word not Found");
                            }
                            temp = temp.next;
                        }
                    }
                }
            }
        }
    }
}


thanks for the help :D

wil0022
Newbie Poster
24 posts since Aug 2009
Reputation Points: 10
Solved Threads: 0
 

sir.. problem solved.. hehe

im sorry... i just want to share and to be helped in debugging..

thanks for you sir.. hehe

i really need to used the LinkedList..

look what is my finished product..

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace LinkedList
{
    class Program
    {
        static void Main(string[] args)
        {
            {
            
                SingleLinkedList list = new SingleLinkedList();
              string balik;
                do
                {
               
            
             
                string choice, meaning, property, word, update, search;
                
               
                Console.WriteLine("\n\n\t\tU - to Update a word and its meaning");
                Console.WriteLine("\t\tI - to Insert a word");
                Console.WriteLine("\t\tS - Search a word and its meaning");
                Console.WriteLine("\t\tV - View all the words in the Dictionary");
                Console.WriteLine("\t\tD - Delete a word and its meaning");
                Console.WriteLine("\t\t(Input should be uppercase, case sensitive)\n\n");
                Console.WriteLine("Enter Your Choice: ");
                choice = Convert.ToString(Console.ReadLine());
                if (choice == "I")
                {
                    //int data = 0;

                    Console.WriteLine("Insert Word: ");
                    word = Console.ReadLine();

                    Console.WriteLine("Meaning: ");
                    meaning = Convert.ToString(Console.ReadLine());

                    Console.WriteLine("Property: ");
                    property = Convert.ToString(Console.ReadLine());

                    list.insertNode(word, meaning, property);
                    Console.WriteLine("\n" + word + " - " + " [" + property + "], " + meaning);
                }
                else
                    if (choice == "S")
                    {
                        Console.Write("Search Word: ");
                        search = Console.ReadLine();
                        list.searchNode(search);


                    }
                    else
                        if (choice == "U")
                        {
                            Console.Write("Enter the word: ");
                            update = Console.ReadLine();
                            list.updateNode(update);


                        }
                        else
                            if (choice == "D")
                            {
                                Console.WriteLine("Delete Word: ");
                                word = Console.ReadLine();
                                list.deleteNode(word);
                            }
                            else
                                if (choice == "V")
                                {
                                    Console.WriteLine("Dictionary: Word and Meaning");
                                    list.traverse();
                                }
                                else
                                    Console.WriteLine("INVALID INPUT.. EROOORRRRRRRR!!");
                  Console.WriteLine("\n\nGusto mo, liwat? [y/nevah!");
                    balik = Console.ReadLine();
                }
                while(balik == "y");
            }             
        }
    }
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace LinkedList
{
    class Node
 {
        private Node _next;
        private string _word;
        private string _meaning;
        private string _property;

        public Node()
        {
            _next = null;
        }
        public Node next
        {
            get
            {
                return _next;
            }
            set 
            {
                _next = value;
            }
        }
        public string word
        {
            get
            {
                return _word;
            }
            set
            {
                _word = value;
            }
        }

            public string meaning
            {
                get
                {
                    return _meaning;
                }
                set
                {
                    _meaning = value;
                }
            }
        public string property
        {
            get
            {
                return _property;
            }
            set
            {
                _property = value;



            }
        }
    }
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace LinkedList
{
    class SingleLinkedList
    {
        public Node head;
        public Node tracer;
        public SingleLinkedList()
        {
            head = null;
            tracer = null;
        }
        public void insertNode(string word, string meaning, string property)
        {
            if (head == null)
            {
                head = new Node();
                tracer = head;
                head.word = word;
                head.meaning = meaning;
                head.property = property;
            }
            else
            {
                Node tempNode = new Node();
                tempNode.word = word;
                tempNode.meaning = meaning;
                tempNode.property = property;
                tracer.next = tempNode;
                tracer = tempNode;

            }
        }
        public void deleteNode(string word)
        {
            Node temp;
            temp = head;

            if (head.word.ToString() == word.ToString())
            {
                head = head.next;
                temp = head;
            }
            else
            {
                while (temp != null && temp.next != null)
                {
                    temp.next = temp.next.next;
                    if (temp.next == null)
                    {
                        tracer = temp;
                    }
                    temp = temp.next;
                }
            }
        }
        public void traverse()
        {
            Node temp = head;
            while (temp != null)
            {
              
                Console.WriteLine(temp.word + " - " + "[" +temp.property + "], " + temp.meaning );
             
                temp = temp.next;
            }
         
        }

        public void searchNode(string word)
        {
            Node temp;
            temp = head;
            if (head.word.ToString() == word.ToString())
            {
                Console.WriteLine(head.word.ToString() + " - " + "[" + head.property.ToString() + "], " + head.meaning.ToString());
               
            }
            else
            {
                while (temp != null && temp.next != null)
                {
                    if (temp.next.word.ToString() == word.ToString())
                    {
                        Console.WriteLine(temp.word.ToString());
                        Console.WriteLine(temp.meaning.ToString());
                        Console.WriteLine(temp.property.ToString());

                        if (temp.next == null)
                        {
                            tracer = temp;
                            break;
                        }
                    }
                    temp = temp.next;
                }
            }
        }
        public void updateNode(string word)
        {
            Node temp;
            temp = head;

            if (head.word.ToString() == word.ToString())
            {
                Console.Write("Word: ");
                head.word = Console.ReadLine();

                Console.Write("Meaning: ");
                head.meaning = Console.ReadLine();

                Console.Write("Property: ");
                head.property = Console.ReadLine();
            }
            else
            {
                while (temp != null && temp.next != null)
                {
                    if (temp.next.word.ToString() == word.ToString())
                    {
                        Console.Write("Word: ");
                        temp.word = Console.ReadLine();

                        Console.Write("Meaning: ");
                        temp.meaning = Console.ReadLine();

                        Console.Write("Property: ");
                        temp.property = Console.ReadLine();
                    }
                    else
                    {
                        while (temp != null && temp.next != null)
                        {
                            if (temp.next.word.ToString() == word.ToString())
                            {
                                Console.Write("Word: ");
                                temp.word = Console.ReadLine();

                                Console.WriteLine("Meaning: ");
                                temp.meaning = Console.ReadLine();

                                Console.WriteLine("Property: ");
                                temp.meaning = Console.ReadLine();

                                if (temp.next == null)
                                {
                                    tracer = temp;
                                    break;
                                }
                            }
                            else
                            {
                                Console.WriteLine("Word not Found");
                            }
                            temp = temp.next;
                        }
                    }
                }
            }
        }
    }
}


:D

wil0022
Newbie Poster
24 posts since Aug 2009
Reputation Points: 10
Solved Threads: 0
 

Hey,

Firstly, im glad to hear you got it working :) Sorry i didnt reply, i had a 50 mile charity bike ride at the weekend so i was away from forums...your thread kinda slipped under the radar after that.

I'm still not entirely sure why you used Linked Lists though. Unless i'm missing something, your nodes arent related to one another; when you look for a node you arent interested in which nodes were added before it. Linked Lists retain thier order making them useful for things like queues and stacks.

What you have done here could easily have been done using a List.
Obviously, if its all working, dont go tearing it apart to rewrite it ;)
But for future reference, i'd recommend looking into collections as they are much easier to use for this sort of project. You create your list then you just use .Add(), .Remove(), .Find() methods.

Remember to mark the thread as solved since you answered your own question :p

Ryshad
Nearly a Posting Virtuoso
1,307 posts since Aug 2009
Reputation Points: 512
Solved Threads: 246
 

sir... i got a lil prob.. how can i make it input more more meaning and more parts of speech..

like
wil- [noun], handsome; [noun], cute.

hehe.. just an example..

wil0022
Newbie Poster
24 posts since Aug 2009
Reputation Points: 10
Solved Threads: 0
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You