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 :(