package Schildt.Chapter5;
class Queue {
    char q[]; // массив для хранения элементов очереди
    int putloc, getloc;
     Queue(int size){
        q = new char[size+1];
        putloc = getloc = 0;
    }
                void put(char ch) {
                if (putloc == q.length - 1){ //
                 System.out.println(" -Очередь заполнена");
                 return;
                }
        putloc++;
        q[putloc] = ch;
       }
         char get () {
           if (getloc == putloc) {
            System.out.println(" - Очередь пуста");
            return (char) 0;
        }
        getloc++;
        return q[getloc];
    }
}
class QDemo {
    public static void main(String args[]) {
        Queue bigQ = new Queue(104);
        Queue smallQ = new Queue(14);
        char ch;
        int i;
        System.out.println("Использование очереди ЬigQ для сохранения алфавита");

        for(i=0; i < 26; i++) // зачем тут цикл?
            bigQ.put((char) ('A' + i)); // что делает эта часть?
        System.out.print("Содержимое очереди ЬigQ: ");
        for (i=0; i < 26; i++) { // что делает эта часть?
            ch = bigQ.get(); // что делает эта часть?
            if (ch != (char) 0) System.out.print(" "+ch);
        }
        System.out.println("\n");

        System.out.println("Использование очереди smallQ для генерации ошибок");
        for(i=0; i < 5; i++) {
            System.out.println("Попытка сохранения " + ( char) ( 'z' - i) ) ; // что делает эта часть?
            smallQ.put((char) ('z' - i));
            System.out.println();
        }
        System.out.println();
        System.out.println("Содержимое smallQ: ");
        for(i=0; i < 5; i++) {
            ch = smallQ.get();
            if (ch != (char) 0) System.out.print(ch);
        }
        }
        }