Skip to content

Instantly share code, notes, and snippets.

@dazsim
Created January 24, 2017 21:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dazsim/e81ad1f71f8c51bae29e72ac6d1c09e6 to your computer and use it in GitHub Desktop.
Save dazsim/e81ad1f71f8c51bae29e72ac6d1c09e6 to your computer and use it in GitHub Desktop.
/*
* 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