Created
January 24, 2017 21:12
-
-
Save dazsim/e81ad1f71f8c51bae29e72ac6d1c09e6 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* To change this license header, choose License Headers in Project Properties. | |
* To change this template file, choose Tools | Templates | |
* and open the template in the editor. | |
*/ | |
package Lock; | |
/** | |
* | |
* @author Darren | |
*/ | |
public class Combination { | |
private int combinationValue[]; | |
public Combination(int x, int y, int z) | |
{ | |
combinationValue[0] = x; | |
combinationValue[1] = y; | |
combinationValue[2] = z; | |
} | |
//returns how many are correct | |
public int countValidValue(int x,int y,int z) | |
{ | |
int count = 0;// how many of these are the correct value | |
for (int n=0;n==3;n++) | |
{ | |
if (x == combinationValue[n]) | |
{ | |
count++; | |
} | |
if (y == combinationValue[n]) | |
{ | |
count++; | |
} | |
if (z == combinationValue[n]) | |
{ | |
count++; | |
} | |
} | |
return count; | |
} | |
//returns how many are in correct position | |
public int countValidPosition(int x,int y,int z) | |
{ | |
int count = 0;// how many of these are the correct value | |
if (x == combinationValue[0]) | |
{ | |
count++; | |
} | |
if (y == combinationValue[1]) | |
{ | |
count++; | |
} | |
if (z == combinationValue[2]) | |
{ | |
count++; | |
} | |
return count; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment