View Single Post
  #2 (permalink)  
Old 06-23-2008, 08:18 PM
Nicholas Jordan's Avatar
Nicholas Jordan Nicholas Jordan is offline
Senior Member
 
Join Date: Jun 2008
Location: Southwest
Posts: 686
Nicholas Jordan is on a distinguished road
A place to start.
Code:
// Ok, very simple - for a game. No supercrunching or anything. // I suppose we could start like this: // A little complicated for a starter effort. class supercruncher { int[][] pwStore = new int[3][4]; supercruncher() { // conceptual - to be coded ..... // We can unroll the loop for simplicity. for(pwStore.length) = passwordAsInt; } // ..... other code here if(checkPassword(int suppliedValue)) { int loopControl = pwStore.length; do { // this next line is not correct if(pwStore.[--loopControl] == suppliedValue) { return true; } } while(loopControl > 0); return false; } }
// This is ineffective - always checking is something one
// would place in the run loop in a game
if(password[0]==""+num1+num2+num3+num4)

Also, for four numbers - the way I have the array is incorrect. Several things in the code are indeterminate until you provide us some feedback....

Last edited by Nicholas Jordan : 06-23-2008 at 08:21 PM. Reason: note errors in code
Reply With Quote