This is a simple black screen console game where first the program will automatically generate a random number, and all the players who play the game here will continue to guess the number one by one and match it with the previous program. The game will end if it matches the program's generated number. Whoever matches will be the winner of this game. Here, we will add another interesting feature which is a counter. What is a counter? It's not just a recorder that will keep recording how many times the player is guessing and how many guesses after which a winner is actually found. After creating the game, we will learn: How to define Class and Object? How to define the accessors of the instance variable How to makes methods? How objects access class methods? Please read the Introduction part of Object Oriented Programming in java, then go forward....:) Background Study of guessing game in java We will create three classes to create this simple game. GameLauncher.java GussesGame.java Player.java GameLauncher.java: The job of this class is to start the game. There will be a main() method here. We will create an object of GuessGame class inside the main method and call the startGame () method. Calling startGame () will start the game. GuessGame.java: In this class, we will create the object of Player class. And in this class, we will create the startGame () method. All logic will be implemented insidestartGame (). Player.java: This class will have the guess () method which will generate a random number for each player. So let's get started, Player.java: package com.guessinggame; public { int number = ; public guess(){ double rand = ( .random()* ); number = (int) rand; System.out.println( +number); } } class Player 0 void Math 100 "I am guessing " GuessGame.java: package com.guessinggame; public { Player p1; Player p2; Player p3; int counter; public startGame(){ counter = ; p1 = Player(); p2 = Player(); p3 = Player(); int guessp1 = ; int guessp2 = ; int guessp3 = ; boolean p1IsRight = ; boolean p2IsRight = ; boolean p3IsRight = ; double rand2 = ( .random()* ); int targetNumber = (int) rand2; System.out.print( +targetNumber); ( ){ counter++; System.out.println( +targetNumber); p1.guess(); p2.guess(); p3.guess(); guessp1 = p1.number; System.out.println( +guessp1); guessp2 = p2.number; System.out.println( +guessp2); guessp3 = p3.number; System.out.println( +guessp3); (guessp1 == targetNumber){ p1IsRight = ; } (guessp2 == targetNumber){ p2IsRight = ; } (guessp3 == targetNumber){ p3IsRight = ; } (p1IsRight || p2IsRight || p3IsRight){ System.out.println( ); System.out.println( + p1IsRight); System.out.println( + p2IsRight); System.out.println( + p3IsRight); System.out.println( ); System.out.println( +counter); ; } { System.out.println( ); } } } } class GuessGame void 0 new new new 0 0 0 false false false Math 100 "I am thinking " while true "Number to guess is " "P1 guessed " "P2 guessed " "P3 guessed " if true if true if true if "Winner Found!!!" "Palayer 1 got it right ? " "Palayer 2 got it right ? " "Palayer 3 got it right ? " "Game is over!!" "Total guessed times is :" break else "No match Found!,Try again..." GameLauncher.java package com.guessinggame; public { public main( [] args){ GuessGame guessGame = GuessGame(); guessGame.startGame(); } } class GameLauncher static void String new wow, great! now you know the objects and classes and how it works and created. HAPPY CODING! To learn more about JAVA OOP click me