CSE102Spring2025 Assignment1
CSE102Spring2025 Assignment1
java
CSE102 Assignment 1
Game Characters and Equipment System
Due: Sunday, 16.03.2025 by 23:59
Deliverables
Submit a single Java file named Assignment01 {StudentNumber}.java via Moodle
by the due date and time specified. Late submissions will be subject to the course’s late policy.
Overview
In this assignment, you will develop a game system that models three types of characters—Warrior,
Mage, and Archer—each with its own inventory and equipment management system. Your pro-
gram should demonstrate the basic Object-Oriented Programming (OOP) principles of inher-
itance and encapsulation. Each derived class defines its own uniquely named methods (e.g.,
warriorAttack, mageAttack, archerAttack) and inherits common inventory/equipment
methods from the base Character class.
Specifications
Your implementation must include the following classes and functionality:
1. Item Class
• Attributes:
– name: String — The item’s name (e.g., “Sword of Might”).
– bonusType: String — The type of bonus provided. Valid values are:
"HEALTH", "MANA", "ACCURACY", "ATTACK".
– bonusValue: int — The bonus value (e.g., 5).
• Methods:
– Item(String name, String bonusType, int bonusValue): Ini-
tializes the attributes.
– Getter methods: getName(), getBonusType(), getBonusValue().
– toString(): Returns a string such as: "Sword of Might [ATTACK
Bonus: 5]".
• Attributes:
– name: String — The character’s name (e.g., “Conan”).
– health: int — The current health points.
– attackPower: int — The base attack power.
1
CSE 102 – Programming Assignment 1 Assignment01 {StudentNumber}.java
a) Warrior Class
• Attributes:
– armor: double — Reduces incoming damage.
– inventory: Item[] — Array with capacity 6.
– equipment: Item[] — Array with 3 slots.
• Methods:
– warriorTakeDamage(int damage, boolean ignoreArmor):
1. If ignoreArmor is true or armor is 0, call takeDamage(damage).
2. Otherwise, calculate damage reduction (10% if armor value is more or
equal to 50; 5% otherwise) and apply the reduced damage.
3. Reduce armor by 10 and print “Current Armor: X.”
4. Print “Current Health: X” after damage is applied.
– warriorAttack(Character target):
1. Compute total attack power = base attack + any ATTACK bonus from
equipment.
2. Attack the target using takeDamage(totalAttackPower).
2
CSE 102 – Programming Assignment 1 Assignment01 {StudentNumber}.java
b) Mage Class
• Attributes:
– mana: int — Mana available for casting spells.
– inventory: Item[] — Array with capacity 2.
– equipment: Item[] — Array with 1 slot.
• Method:
– mageAttack(Character target):
1. If mana value is greater or equal to 10, compute spell damage = total
attack power (base + ATTACK bonus) + 5.
2. Apply damage to the target and reduce mana by 10.
3. Print “Mage’s Remaining Mana: X” (showing current mana).
4. Otherwise, perform a basic attack.
• Inventory and equipment methods work similarly to those in the Warrior class.
c) Archer Class
• Attributes:
– accuracy: int — Determines the chance for a critical hit.
– inventory: Item[] — Array with capacity 4.
– equipment: Item[] — Array with 2 slots.
• Method:
– archerAttack(Character target):
1. Calculate total attack power = base attack + any ATTACK bonus.
2. If (base accuracy + any ACCURACY bonus) is greater than 80, add an
extra 5 damage.
3. Attack the target with the computed damage.
• Inventory and equipment methods are implemented similarly to those in the
Warrior class.
3
CSE 102 – Programming Assignment 1 Assignment01 {StudentNumber}.java
Output Example