Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.company;
- import java.sql.SQLOutput;
- import java.util.Scanner;
- import java.util.Random;
- public class Main {
- public static void main(String[] args) {
- Random rand= new Random();
- Scanner Keyboard= new Scanner(System.in);
- int randomnumber = rand.nextInt();
- char [] word1 = {'g','e','n','g','a','r'};
- char [] word2 = {'e','s','p','e','o','n'};
- char dash [] = {'-','-','-','-','-','-'};
- String misses = "Misses: ";
- int tries = 0;
- while(true) {
- int total = 0;
- System.out.println("-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-");
- System.out.print("Word: ");
- for (int i = 0; i < dash.length; i++) {
- System.out.print(dash[i] + " ");
- }
- Scanner keyboard = new Scanner(System.in);
- System.out.print("\n" + misses);
- System.out.print("\nGuess:");
- String input = keyboard.next();
- for (int i = 0; i < dash.length; i++) {
- if (input.charAt(0) == word1[i]) {
- dash[i] = word1[i];
- total++;
- }
- }
- if(total == 0){
- misses = misses + input;
- }
- tries++;
- if (tries==10){
- System.out.println("-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-");
- System.out.println("GAME OVER");
- System.out.println("The word was " + word1);
- break;
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement