Submission 1: Classes and Objects

Objective: Introduce classes and objects by creating the fundamental components of the game.

Instructions:

  1. Create a Player Class:

    • Attributes:

      • String name

      • int health

      • int attackPower

    • Methods:

      • void attack(Enemy enemy)

      • void takeDamage(int damage)

    • Constructor: Initialize the player's name (input by the user), health (e.g., 100), and attack power (e.g., 10).

  2. Create an Enemy Class:

    • Attributes:

      • String name

      • int health

      • int attackPower

    • Methods:

      • void attack(Player player)

      • void takeDamage(int damage)

    • Constructor: Initialize the enemy's name, health (e.g., 50), and attack power (e.g., 5).

  3. Implement the Main Game Loop:

    • In the main method, create instances of Player and Enemy.

    • Simulate a simple combat scenario where the player and the enemy take turns attacking each other until one's health drops to zero.

    • Display combat messages indicating actions and health status.

Deliverables:

  • Source code files (Player.java, Enemy.java, and Main.java).

  • Screenshot of the program output

COSC-1437 / ITSE-2457 Computer Science Dept. - Author: Dr. Kevin Roark