Search
 
SCRIPT & CODE EXAMPLE
 

JAVA

number guessing game in java using oops

import java.util.Scanner;

public class Game {
    private Scanner input;
    private Player player;
    private GuessNumberGame guessNumberGame;
    private boolean running;
    private String command;

    Game() {
        this.player = new Player();
        this.input = new Scanner(System.in);
        this.guessNumberGame = new GuessNumberGame(20);
        this.running = true;
    }

    public void init() {
        while (running) {
            System.out.println("commands: leave, play");
            System.out.print(">> ");
            this.command = this.input.next();

            if (this.command.equals("leave")) {
                this.running = false;
            } else if (command.equals("play")) {
                this.player.play(this.input, this.guessNumberGame);
                this.guessNumberGame.setSecretNumber(20);

            } else {
                System.out.println("unknown command");
            }
        }
    }
}
Comment

PREVIOUS NEXT
Code Example
Java :: Java Labeled continue Statement Java 
Java :: retrofit with api key post 
Java :: javax.servlet.Filter 
Java :: find maximum number of rides in amusement park python 
Java :: lelen suratlari ramkasidagi oltinlar 
Java :: how to set up basic java workspace 
Java :: Java Creating a LinkedHashMap 
Java :: how to select multiple non-consecutive words on mac 
Java :: android diagonal gradle 
Java :: The root directory of the External Storage on every android version 
Java :: extended window style values in java 
Java :: java datasource 
Java :: jwt token in android studio 
Java :: sorted hashmap java 
Java :: Java Throwing checked exception 
Java :: tipo map que permite armazenar na mesma chave java 
Java :: nbubble sort java 
Java :: Java @Retention 
Java :: how to run the war file in Apache Tomcat/8.5.59 THROUGH SPRING 
Java :: geometric primitive 
Java :: Not allowed to bind to service Intent 
Java :: before first in jdbc 
Java :: zombie testing java 
Java :: randpm years java 
Java :: java replace second char of a string 
Java :: kano magic wand 
Java :: java to kotlin online convertor 
Java :: jsonStringToMap 
Java :: 3x+1 in java 
Java :: how to extract value from payload in java 
ADD CONTENT
Topic
Content
Source link
Name
4+8 =