Skip to content

YuriiJavaDev/JavaBasics_Task_11

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 

Repository files navigation

Hero Health Tracking (JavaBasics_Task_11)

📌 Description

This project simulates tracking a character's health in a game environment. It demonstrates the practical use of unary operators: increment (++) and decrement (--).

🚀 Task Requirements

  1. Declare an int variable heroHealth and set it to 10.
  2. Increase health by 1 using the increment operator and display the result.
  3. Decrease health by 1 using the decrement operator.
  4. Print the final value of heroHealth again. Include descriptions of game moments in the console output.

📋 Expected Output

After running the program, the console should display:

Health after bonus: 11, because the hero found the cure.
Health after damage: 10, because a brick fell on the hero.

🛠 Technical Stack

  • Language: Java 23
  • IDE: IntelliJ IDEA
  • Concepts: Increment/Decrement operators, Variable state management.

⌨️ Practical Implementation

The code follows Java naming conventions and clean code principles. Each state change is followed by an informative console message.

💻 Code Example

The code demonstrates how the state of a single variable changes after applying unary operators:

package com.yurii.pavlenko;

public class Task_11_App {
   public static void main(String[] args) {
      // Initial health level
      int heroHealth = 10;

      // Increase health by 1 using increment operator
      heroHealth++;
      System.out.println("Health after bonus: " + heroHealth + ", because the hero found the cure.");

      // Decrease health by 1 using decrement operator
      heroHealth--;
      System.out.println("Health after damage: " + heroHealth + ", because a brick fell on the hero.");
   }
}

⚖️ License

This project is licensed under the MIT License.

Copyright (c) 2026 Yurii Pavlenko

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files...

License: MIT

About

This is a training project (JavaBasics_Task_11). It demonstrates the use of increment and decrement operators using the example of tracking a game hero's health.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages