Queuebuilding. [modified]
-
Seeking help with the last blocks of codes numbered 1 and 2 on the forme1.cs and queue.cs shown below.? It all working well. Stack on the last blocks. FORM 1.CS using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Text; using System.Windows.Forms; namespace Queuebuilder { public partial class Form1 : Form { public Form1() { myQueue = new queue(); myQueue.queue_init(); InitializeComponent(); } queue myQueue; // making a queue empty private void initbutton_Click(object sender, EventArgs e) { myQueue.queue_init(); displayQueue(); } // enqueueing an item private void enqueuebutton_Click(object sender, EventArgs e) { int val; try { val = Convert.ToInt32(inputBox.Text); inputBox.Clear(); } catch { MessageBox.Show("Please enter an integer."); inputBox.Focus(); return; } myQueue.enqueue(val); displayQueue(); inputBox.Focus(); } // private void dequeuebutton_Click(object sender, EventArgs e) { myQueue.dequeue(); displayQueue(); //displayBox.Focus(); } // displaying queue contents private void displayQueue() { string displayString; displayString = myQueue.printQueue(); displayBox.Clear(); displayBox.AppendText(displayString); displayBox.AppendText("\n"); } 1. // Trying to remove every second item private void evenitemsbutton_Click(object sender, EventArgs e) { myQueue.dequeue(); displayQueue(); } 2. // Trying to reverse the queue private void reversebutton_Click(object sender, EventArgs e) { } } } ------------------------------------------------------------ QUEUE.CS using System; using System.Collections.Generic; using System.Text; namespace Queuebuilder { class queuenode { public int nodedata; publ
-
Seeking help with the last blocks of codes numbered 1 and 2 on the forme1.cs and queue.cs shown below.? It all working well. Stack on the last blocks. FORM 1.CS using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Text; using System.Windows.Forms; namespace Queuebuilder { public partial class Form1 : Form { public Form1() { myQueue = new queue(); myQueue.queue_init(); InitializeComponent(); } queue myQueue; // making a queue empty private void initbutton_Click(object sender, EventArgs e) { myQueue.queue_init(); displayQueue(); } // enqueueing an item private void enqueuebutton_Click(object sender, EventArgs e) { int val; try { val = Convert.ToInt32(inputBox.Text); inputBox.Clear(); } catch { MessageBox.Show("Please enter an integer."); inputBox.Focus(); return; } myQueue.enqueue(val); displayQueue(); inputBox.Focus(); } // private void dequeuebutton_Click(object sender, EventArgs e) { myQueue.dequeue(); displayQueue(); //displayBox.Focus(); } // displaying queue contents private void displayQueue() { string displayString; displayString = myQueue.printQueue(); displayBox.Clear(); displayBox.AppendText(displayString); displayBox.AppendText("\n"); } 1. // Trying to remove every second item private void evenitemsbutton_Click(object sender, EventArgs e) { myQueue.dequeue(); displayQueue(); } 2. // Trying to reverse the queue private void reversebutton_Click(object sender, EventArgs e) { } } } ------------------------------------------------------------ QUEUE.CS using System; using System.Collections.Generic; using System.Text; namespace Queuebuilder { class queuenode { public int nodedata; publ
-
-
-
1. You can use the
ToArray
method ofQuery
class to get the array of items. 2. UseArray.Reverse
method for reversing it. 3. Create a new queue instance with the reversed array. Note: I won't be giving the code as it seems to be a home work*jaans