• Post Reply Bookmark Topic Watch Topic
  • New Topic

Newbie help with "while" statements.  RSS feed

 
Roger Carlisle
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello! I'm new to the world of programming and after a few weeks in my Java class have run into some homework trouble. We've been working the the Java Au Naturel book and the current assignment is to:

"Write a query method public boolean sameNumber (Vic par) for Looper: The executor tells whether it has the same number of CDs in its slots as the Vic parameter. Do not use numeric variables"

I put together something I thought would work, but somewhere I think the "while" statements are messing it up.

Any help would be much appreciated.


Thanks.

Here's the class I wrote to fulfill this assignment



The main "Vic" class which everything runs off of and uses to set up situations



Sorry that that was so long. It's needed for testing
 
Campbell Ritchie
Marshal
Posts: 56536
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the Ranch

That isn’t newbies’ code. I suggest you create a similar while loop, and a simple class which returns false or true to continue the loop. Try text/command line input to get different return values, and see what happens. Then you can familiarise yourself with the workings of a while loop.
You ought to say what is going wrong; without full details, nobody can help.
 
Jeff Verdegan
Bartender
Posts: 6109
6
Android IntelliJ IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Roger Carlisle wrote:

Sorry that that was so long. It's needed for testing


Then you should create an SSCCE that demonstrates the problem. You might be able to do that by stripping stuff out of that code, or it might be easier just to create it from scratch. I can't speak for others, but I won't even consider reading that much code.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!