Im trying to make a circular queue. Why does empty keep saying my q is empty?
using System;
namespace CQueue
{
class Program
{
static void Main(string[] args)
{
List queue = new List();
Double number = 9.13;
queue.Enqueue(number);
queue.Enqueue(number);
queue.PrintQueue();
}
}
}
class List
{
object[] thisIsQ = new object[10];
int head = 0;
int tail = 0;
public void Enqueue(object insert)
{
if (IsEmpty())
{
thisIsQ[tail] = insert;
tail = Counter(tail);
}
}
public void PrintQueue()
{
if (Empty())
{
Console.WriteLine("Queue is Empty.");
}
}
public bool Empty()
{
return (tail == 0 && head == 0);
}
public int Counter(int x)
{
return (x) % thisIsQ.Length;
}
}