Help with queuenodes/linked list in C#?
I have a class that records weights and tag numbers into seperate nodes using a queue and a linked list.I have two buttons,one to print the data into record the data into the queue and one to print the queue.
I have 2 problems.
1.What do I put into the print button to print the value in the queue?
2.When I press the the print and record buttons,I cant see the queue in the rich textBox.How do I append values so they show up in the queue?
This is my class.
amespace WindowsApplication1
{
class queueNode
{
private queueNode mNext;
private int mTagNumber;
private int mWeights;
public queueNode(int pTagNumber, int pWeights)
{
mTagNumber = pTagNumber;
mWeights = pWeights;
mNext = null;
}
public int Weights
{
get { return mWeights; }
set { this.mWeights = value; }
}
public int TagNumber
{
get { return mTagNumber; }
set { this.mTagNumber = value; }
}
public queueNode Next
{
get { return mNext; }
set { this.mNext = value; }
}
public override string ToString()
{
return "Weights: " + mWeights.ToString() + "\nTag Number: " +
mTagNumber.ToString();
}
}
}
and this is my form one.
namespace WindowsApplication1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
queueNode first = null;
queueNode last = null;
public void DeQueue()
{
first = first.Next;
}
private void button2_Click(object sender, EventArgs e)
{
int num = Convert.ToInt32(textBox1.Text);
int weight = Convert.ToInt32(textBox2.Text);
queueNode mNode = new queueNode(num, weight);
if (first == null)
{
first = last = mNode;
}
else
{
last.Next = mNode;
last = mNode;
}
}
private void button1_Click(object sender, EventArgs e)
{ // what do I put in here to make my queue print a value from the queue into rich textbox?//
}
}
}
any help would be great.Im still trying to learn so get quite stuck.Thanks so much for your help
sorry for the spelling errors,only just realised :S
|