Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package ch10ex5;
- import java.util.Scanner;
- public class Ch10Ex5
- {
- public static void main(String[] args)
- {
- Scanner sc=new Scanner(System.in);
- System.out.println("Welcome to Mastermind!");
- System.out.println("Enter the number of pegs (1-10): ");
- int pegs=sc.nextInt();
- System.out.println("Emter the number of colors (1-9): ");
- int colors=sc.nextInt();
- mastermindGame mastermindGame=new mastermindGame(pegs,colors);
- mastermindGame.generate();
- for(int c=1;true;c++)
- {
- for(int x=1;x<=pegs;x++)
- {
- System.out.println("Color for peg "+x+": ");
- int temp=sc.nextInt();
- mastermindGame.checkEach(temp,x);
- }
- mastermindGame.game();
- if(mastermindGame.win==true)
- {
- System.out.println("You have broken the code in "+c+" guesses.");
- break;
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement