Richard_Sekol

comlock project8.1

Nov 25th, 2014
145
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.00 KB | None | 0 0
  1. package comlock;
  2. import java.util.Random;
  3. import java.util.Scanner;
  4. public class comLockProgram {
  5. Random comboSet = new Random();
  6. Scanner input = new Scanner(System.in);
  7. int com1, com2, com3, ticks, set1, set2, set3;
  8. int dial = 0;
  9. public comLockProgram(int num1, int num2, int num3){
  10. //int num1 = input.nextInt();
  11. //int num2 = input.nextInt();
  12. //int num3 = input.nextInt();
  13. if (num1 < 0){com1 = comboSet.nextInt(39);}
  14. else{com1 = num1;}
  15. if (num2 < 0){com2 = comboSet.nextInt(39);}
  16. else{com2 = num2;}
  17. if (num3 < 0){com3 = comboSet.nextInt(39);}
  18. else{com3 = num3;}
  19. }
  20. //following 5 lines not needed due to changing to an electrical lock
  21. //public void reset(){dial = 0;}
  22. //public void turnLeft(int tick)
  23. //{dial = dial + tick;}
  24. //public void turnRight(int tick)
  25. //{dial = dial + tick;}
  26. public boolean open()
  27. {if (set1 == com1 && set2 == com2 && set3 == com3){return true;}
  28. else {return false;}
  29. }
  30. public void numSet(){
  31. set1 = input.nextInt();
  32. set2 = input.nextInt();
  33. set3 = input.nextInt();
  34. }
  35. }
Advertisement
Add Comment
Please, Sign In to add comment