Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class FixedQueue implements ICharQ {
- private char q[];
- private int putloc, getloc;
- public FixedQueue(int size) {
- q = new char[size+1];
- putloc = getloc = 0;
- }
- @Override
- public void put(char ch) {
- if(putloc == q.length-1){
- System.out.println(" - Queue is full.");
- return;
- }
- putloc++;
- q[putloc] = ch;
- }
- @Override
- public char get() {
- if(getloc == putloc) {
- System.out.println(" - Queue is full.");
- return (char) 0;
- }
- getloc++;
- return q[getloc];
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement