#APPTYPE CONSOLE REM Create a CircularQueue object REM CQ.Store item REM CQ.Find items REM CQ.Forward nItems REM CQ.Recall REM SO CQ init WITH "A"... "Z" REM CQ.Find "B" REM QC.Forward 13 REM QC.Recall CLASS CircularQueue items[] head tail here SUB INITIALIZE(dArray) head = 0 tail = 0 here = 0 FOR DIM i = LBOUND(dArray) TO UBOUND(dArray) items[tail] = dArray[i] tail = tail + 1 NEXT END SUB SUB TERMINATE() REM END SUB METHOD Put(s AS STRING) items[tail] = s tail = tail + 1 END METHOD METHOD Find(s AS STRING) FOR DIM i = head TO tail - 1 IF items[i] = s THEN here = i RETURN TRUE END IF NEXT RETURN FALSE END METHOD METHOD Move(n AS INTEGER) DIM bound AS INTEGER = UBOUND(items) + 1 here = (here + n) MOD bound END METHOD METHOD Recall() RETURN items[here] END METHOD PROPERTY Size() RETURN COUNT(items) END PROPERTY END CLASS DIM CQ AS NEW CircularQueue({"A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z"}) DIM c AS STRING DIM isUppercase AS INTEGER DIM s AS STRING = "nowhere ABJURER" FOR DIM i = 1 TO LEN(s) c = MID(s, i, 1) isUppercase = lstrcmp(LCASE(c), c) IF CQ.Find(UCASE(c)) THEN CQ.Move(13) PRINT IIF(isUppercase, UCASE(CQ.Recall()), LCASE(CQ.Recall())) ; ELSE PRINT c; END IF NEXT PAUSE