Advertisement
KeeganT

Ch10Ex5 Main

Mar 26th, 2019
125
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.00 KB | None | 0 0
  1. package ch10ex5;
  2. import java.util.Scanner;
  3.  
  4. public class Ch10Ex5
  5. {
  6.     public static void main(String[] args)
  7.     {
  8.         Scanner sc=new Scanner(System.in);
  9.         System.out.println("Welcome to Mastermind!");
  10.         System.out.println("Enter the number of pegs (1-10): ");
  11.         int pegs=sc.nextInt();
  12.         System.out.println("Emter the number of colors (1-9): ");
  13.         int colors=sc.nextInt();
  14.         mastermindGame mastermindGame=new mastermindGame(pegs,colors);
  15.         mastermindGame.generate();
  16.         for(int c=1;true;c++)
  17.         {
  18.             for(int x=1;x<=pegs;x++)
  19.             {
  20.                 System.out.println("Color for peg "+x+": ");
  21.                 int temp=sc.nextInt();
  22.                 mastermindGame.checkEach(temp,x);
  23.             }
  24.             mastermindGame.game();
  25.             if(mastermindGame.win==true)
  26.             {
  27.                 System.out.println("You have broken the code in "+c+" guesses.");
  28.                 break;
  29.             }
  30.         }
  31.     }
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement