import java.util.Scanner;
public class combinationLock
{
//Sets the combination lock to C O I
public char FIRST_LETTER='C';
public char SECOND_LETTER='O';
public char THIRD_LETTER='I';
//Declare the 3 inputs of the user
public char first_input;
public char second_input;
public char third_input;
public static void main(String args[])
//Start getting their first letter
System.out.println("Please enter in the first letter in the combination: ");
char first_input=numbers.next().charAt(0);
Character.toUpperCase(first_input);
//Start getting their second letter
System.out.println("Please enter in the second letter in the combination: ");
char second_input=numbers.next().charAt(0);
Character.toUpperCase(second_input);
//Start getting their second letter
System.out.println("Please enter in the third letter in the combination: ");
char third_input=numbers.next().charAt(0);
Character.toUpperCase(third_input);
//Begin running the methods to begin lock comparison
lock.lockComparison1(first_input);
lock.lockComparison2(second_input);
lock.lockComparison3(third_input);
//Start the methods for the lock combination testing
public char lockComparison1(char first_input)
{
boolean first;
if(first_input=='C')
{
first=true;
System.out.println("Your first guess, \"C\" is correct.");
}
else if(first_input==SECOND_LETTER || first_input==THIRD_LETTER)
{
System.out.println("Your first guess, \""+first_input+"\" was not the first letter in the combination, yet it is used in the actual combination");
first=false;
}
else if(first_input!=SECOND_LETTER || first_input!=THIRD_LETTER)
{
System.out.println("You entered \""+first_input+"\" but it isn't a letter in any part of this combination.");
}
return first_input;
}
public char lockComparison2(char second_input)
{
boolean second;
if(second_input=='O')
{
second=true;
System.out.println("Your second guess, \"O\" is correct.");
}
else if(second_input==FIRST_LETTER || second_input==THIRD_LETTER)
{
System.out.println("Your second guess, \""+second_input+"\" was not the second letter in the combination, yet it is used in the actual combination");
second=false;
}
else if(second_input!=FIRST_LETTER || second_input!=THIRD_LETTER)
{
System.out.println("You entered \""+second_input+"\" but it isn't a letter in any part of this combination.");
}
return second_input;
}
public char lockComparison3(char third_input)
{
boolean third;
if(third_input=='I')
{
third=true;
System.out.println("Your third guess, \"I\" is correct.");
}
else if(third_input==FIRST_LETTER || third_input==SECOND_LETTER)
{
System.out.println("Your third guess, \""+third_input+"\" was not the third letter in the combination, yet it is used in the actual combination");
third=false;
}
else if(third_input!=SECOND_LETTER || third_input!=FIRST_LETTER)
{
System.out.println("You entered \""+third_input+"\" but it isn't a letter in any part of this combination.");
}
return third_input;
}
}
Friday, March 20, 2009
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment