Skip to content

UbaidullahWaheed/DecodeLabs-NumbersGame-P1

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🎯 Number Guessing Game — Java Console Application

Java Console App OOP Status

Project 1 · Java Programming Internship @ DecodeLabs

A crash-proof, logic-driven number guessing engine built with Core Java

▶ Demo · ⚙️ Features · 🧠 Concepts Used · 🚀 Getting Started


📌 Overview

This is my first project from the Java Programming Internship at DecodeLabs. While it looks like a simple game on the surface, it's really an exercise in clean logic, robust state management, and writing crash-proof software.

The game generates a random number between 1 and 100, gives you limited attempts to guess it, provides High/Low feedback after each guess, tracks your score across multiple rounds, and never crashes — no matter what you type.


✨ Features

Feature Description
🎲 Random Number Generation Fresh random number (1–100) every round using java.util.Random
📥 User Input Handling Real-time input via java.util.Scanner with full validation
🔁 High / Low Feedback Instant directional hints after every guess
⏳ Attempt Limiter Fixed number of attempts per round — run out and it's Game Over
🏆 Score Tracking Persistent score across multiple rounds in one session
🔄 Multiple Rounds Play again without restarting the program
🛡️ Input Validation try-catch handles InputMismatchException — completely crash-proof

🧠 Java Concepts Applied

java.util.Random      →  Stochastic number generation
java.util.Scanner     →  Stream-based user input capture
while loop            →  Game state management per round
if-else conditionals  →  High / Low feedback logic
try-catch block       →  InputMismatchException handling
do-while loop         →  Session persistence (multiple rounds)

🚀 Getting Started

Prerequisites

  • Java JDK 8 or higher installed
  • A terminal / command prompt

Run Locally

# 1. Clone the repository
git clone https://github.com/YOUR_USERNAME/number-guessing-game.git

# 2. Navigate into the project directory
cd number-guessing-game

# 3. Compile the Java file
javac NumberGuessingGame.java

# 4. Run the program
java NumberGuessingGame

🎮 Demo

==========================================
   Welcome to the Number Guessing Game!
==========================================
I'm thinking of a number between 1 and 100.
You have 7 attempts. Good luck!

Attempt 1/7 → Enter your guess: 50
📉 Too Low! Try higher.

Attempt 2/7 → Enter your guess: 75
📈 Too High! Try lower.

Attempt 3/7 → Enter your guess: 63
🎉 Correct! You guessed it in 3 attempts!

Your Score: 1 | Play again? (yes/no): yes

📁 Project Structure

number-guessing-game/
│
├── NumberGuessingGame.java   # Main game logic
└── README.md                 # Project documentation

💡 What I Learned

"A working game is good. A crash-proof game is professional." — DecodeLabs

This project taught me that programming is fundamentally about logic, not just syntax. Key takeaways:

  • Managing program state across loops and rounds
  • Handling edge cases gracefully without crashing
  • Using exception handling as a design tool, not an afterthought
  • Writing code that is predictable and reliable for the end user

👨‍💻 Author

Ubaidullah Waheed Java Intern @ DecodeLabs

LinkedIn GitHub


📄 License

This project is open source and available under the MIT License.


Made with ☕ and Core Java · DecodeLabs Internship 2024

About

Java Number Guessing Game | DecodeLabs Industrial Training 2026

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages