Internal Void? как правильно аргумент преобразовать в int - C#
Формулировка задачи:
using System;
using ConsoleApp2;
using ConsoleApp2.Fifo;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleAppTest
{
class Program
{
static void Main(string[] args)
{
bool isClose = false;
string oper;
Fifotablicowa<liczba> Fifo = new Fifotablicowa<liczba>(10);
while (!isClose)
{
Console.Clear();
Console.WriteLine("KOLEJKA TABLICOWA");
Console.WriteLine();
Console.WriteLine("D - dodaj element kolejki");
Console.WriteLine("U - usun element kolejki");
Console.WriteLine("C - exit");
Console.WriteLine();
Console.Write("KOLEJKA -> ");
Fifo.Print();
Console.WriteLine();
Console.Write("Podaj operacje: ");
oper = Console.ReadLine();
oper = oper.ToUpper();
if (oper == "D")
{
Random rnd = new Random();
liczba l = new liczba(rnd.Next(100));
Fifo.Enqueue(1);
}
else if (oper == "U")
{
Fifo.Dequeue();
}
else if (oper == "C")
{
isClose = true;
}
}
}
}
}Решение задачи: «Internal Void? как правильно аргумент преобразовать в int»
textual
Листинг программы
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApp2.Fifo
{
public class Fifotablicowa<E> where E : class
{
object[] tablica;
readonly int size = 0;
int head = 0;
int tail = 0;
public Fifotablicowa(int rozmiar)
{
size = rozmiar;
tablica = new Object[size];
}
public void Enqueue(Encoder wartosc)
{
if (IsFull())
throw new StackOverflowException();
else
{
tablica[tail] = wartosc;
tail = (tail + 1) % size;
if (tail == head)
tail = -1;
}
}
public E Dequeue()
{
if (IsEmpty())
return null;
else
{
object toReturn = tablica[head];
tablica[head] = null;
if (IsFull())
tail = head;
head++;
if (head >= size)
head = 0;
return (E)toReturn;
}
}
public bool IsFull()
{
if (tail == -1)
return true;
else return false;
}
public bool IsEmpty()
{
if (head == tail)
return true;
else return false;
}
public void Print()
{
if (head == 0)
{
Console.WriteLine("Stos pusty");
}
else
{
for (int i =0; i < tail; i++)
{
Console.Write(tablica[i]);
Console.Write("|");
}
Console.WriteLine();
}
}
}
}