示例#1
0
 public classStack(classStack obj, int indx, int a)
 {
     this.indx = indx;
     stck = new char[obj.stck.Length + a];
     if (a > 0)
     {
         for (int i = 0; i < obj.stck.Length; i++)
             stck[i] = obj.stck[i];
     }
     else
     {
         for (int i = 0; i < stck.Length; i++)
             stck[i] = obj.stck[i];
     }
 }
示例#2
0
    static void Main()
    {
        Console.WriteLine("Editing on GitHub here");
        classArray arr = new classArray();
        classStack sta = new classStack();
        classQueue que = new classQueue();
        string choice;
        do
        {

            Console.WriteLine("1.ArrayList\n2.Stack\n3.Queue");
            string ch;
            ch = Console.ReadLine();
            switch (ch)
            {
                case "1": arr.start();
                    break;
                case "2": sta.start();
                    break;
                case "3": que.start();
                    break;
                default:
                    Environment.Exit(0);
                    break;
            }
            Console.WriteLine("Do You wish to continue?\nY / N");
            choice = Console.ReadLine();
        } while (choice == "y" || choice == "Y");
    }
示例#3
0
 private void IncreaseSize()
 {
     Console.Write("На сколько увеличить: ");
     stack = new classStack(stack, stack.GetIndex(), Convert.ToInt32(Console.ReadLine()));
 }
示例#4
0
 private void IncreaseSize(string inputStr)
 {
     int inc = stack.GetIndex() + inputStr.Length - stack.Capacity();
     string command;
     Console.Write("\nУвеличить размер стека? (yes/no) ");
     command = Console.ReadLine();
     switch (command)
     {
         case "yes":
             stack = new classStack(stack, stack.GetIndex(), inc);
             break;
         case "y":
             stack = new classStack(stack, stack.GetIndex(), inc);
             break;
         case "no":
             break;
         case "n":
             break;
         default:
             Console.Clear();
             Console.WriteLine("error\n\terror\n\t\terror\n\t\t\terror\n\t\t\t\terror\n\n\nне вводи всякую херню\n\n\nжмакни Enter");
             Console.ReadLine();
             Console.Clear();
             return;
     }
     return;
 }
示例#5
0
 private void DecreaseSize()
 {
     string command;
     int dec = 0;
     int indx = 0;
     Console.Write("Уменьшение размера может привести к потере данных\nВы уверены? (yes/no) ");
     command = Console.ReadLine();
     switch (command)
     {
         case "yes":
             break;
         case "y":
             break;
         case "no":
             return;
         case "n":
             return;
         default:
             Console.Clear();
             Console.WriteLine("error\n\terror\n\t\terror\n\t\t\terror\n\t\t\t\terror\n\n\nне вводи всякую херню\n\n\nжмакни Enter");
             Console.ReadLine();
             Console.Clear();
             return;
     }
     Console.Write("На сколько уменьшить: ");
     dec = Convert.ToInt32(Console.ReadLine());
     /*блок проверок*/
     if (dec > stack.Capacity())
     {
         Console.WriteLine("\nПревышает общий размер стека. Операция невозможна");
         Console.ReadLine();
         return;
     }
     indx = stack.GetIndex() > (stack.Capacity() - dec) ? (stack.Capacity() - dec) : stack.GetIndex();
     /*-------------*/
     stack = new classStack(stack, indx, -dec);
 }
示例#6
0
 public StackDrv()
 {
     Console.Write("Размер стека: ");
     stack = new classStack(Convert.ToInt32(Console.ReadLine()));
     Menu();
 }