• Post Reply Bookmark Topic Watch Topic
  • New Topic

Interfaces demo not producing expected output  RSS feed

 
paul a carron
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I'm probably missing something really obvious.

I have the below interfaces demo:



This is the output I get:


This is the output I expect:


My issue seems to be with the CircularQueue class but I've been staring at it for a while now and can't see the issue.

Cheers
Paul
 
Norman Radder
Ranch Hand
Posts: 146
4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It looks like the fixed queue and the dynamic queue code does what you want and there are problems with the circular queue.   Is that correct?

How are you trying to debug the code to find the problem?


 
paul a carron
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, that's correct.

As far as debugging is concerned. I wondered why the queue is full message appears. Obviously the requirements of the if are met in the put method. To check this I added the below to the if:



It returned a value of 9 for putloc and 10 for getloc which agrees with



I guess this is explains that but I'm not sure why it returns the 9 & 10 values.

By adding similar println's to various parts of my CircularQueue and IQDemo I can see that nothing is getting put into the queue so there's nothing to return, hence the blank spaces.

That's as far as I've got.
 
Norman Radder
Ranch Hand
Posts: 146
4
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I added the below to the if:

I think it would be more useful if the print out was BEFORE the if statement.
Also it could be done in one statement and the values should have labels to identify what they are:
 
 
paul a carron
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ah thanks. I had a few silly mistakes that I didn't spot when I was looking at it earlier.

In CircularQueue I changed


for


In IQDemo I also changed


for


All working as expected now.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!