Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package programs;
- import java.util.Scanner;
- public class TalhasShittyCode {
- public static void main(String[] args) {
- // TODO Auto-generated method stub
- Scanner input = new Scanner (System.in);
- int guess = 10;
- int numGuess = 0;
- int max = 3;
- int min = 1;
- int peg1 = 0;
- int peg2 = 0;
- int peg3 = 0;
- int correct = 0;
- int randLoop1 = 0;
- int randLoop2 = 0;
- String string1 = "";
- String string2 = "";
- String string3 = "";
- String guess1 = "";
- String guess2 = "";
- String guess3 = "";
- do {
- do {
- peg1 = (int)(Math.random()*(max) + min); //peg1 = (int)Math.random()*(max) + min; why does this only print one
- if (peg1 == 1) {
- string1 = "R";
- }
- else if (peg1 == 2) {
- string1 = "G";
- }
- else if (peg1 == 3){
- string1 = "B";
- }
- randLoop1++;
- }while (randLoop1 < 1);
- randLoop2++;
- do {
- peg2 = (int)(Math.random()*(max) + min);
- if (peg2 == 1) {
- string2 = "R";
- }
- else if (peg2 == 2) {
- string2 = "G";
- }
- else if (peg2 == 3){
- string2 = "B";
- }
- randLoop1++;
- }while (randLoop1 < 2);
- randLoop2++;
- do {
- peg3 = (int)(Math.random()*(max) + min);
- if (peg3 == 1) {
- string3 = "R";
- }
- else if (peg3 == 2) {
- string3 = "G";
- }
- else if (peg3 == 3){
- string3 = "B";
- }
- randLoop1++;
- }while (randLoop1 < 3);
- randLoop2++;
- }while(randLoop2 <=3);
- System.out.println("Welcome to Mastermind! You have ten guesses to guess the hidden combination of coloured pegs.");
- System.out.println("The possible colours are red (R), green (G) and blue (B)");
- System.out.println("Enter in your guess as a capital letters, ie RGB");
- do {
- System.out.println("You have " + guess-- + " guesses left.");
- System.out.println("Enter in your first peg");
- guess1 = input.next();
- System.out.println("Enter in your second peg");
- guess2 = input.next();
- System.out.println("Enter in your third peg");
- guess3 = input.next();
- correct = 0;
- if (guess1.equals(string1)) {
- correct++;
- }
- if (guess2.equals(string2)) {
- correct++;
- }
- if (guess3.equals(string3)) {
- correct++;
- }
- System.out.println("You got " + correct + " pegs correct");
- numGuess++;
- }while((correct != 3) && (numGuess < 10));
- if (correct == 3) {
- System.out.println("Congratulations you got them all");
- }
- else{
- System.out.println("You fail.");
- System.out.println("like everything else you have ever done in your life");
- System.out.println("goodbye I dont have time for plebs");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement