Submission 1: Classes and Objects
Objective: Introduce classes and objects by creating the fundamental components of the game.
Instructions:
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).
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).
Implement the Main Game Loop:
In the
main
method, create instances ofPlayer
andEnemy
.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
, andMain.java
).Screenshot of the program output
COSC-1437 / ITSE-2457 Computer Science Dept. - Author: Dr. Kevin Roark