0% found this document useful (0 votes)
37 views4 pages

CSE102Spring2025 Assignment1

The CSE 102 Programming Assignment 1 requires students to create a game system in Java that models three character types: Warrior, Mage, and Archer, each with unique inventory and equipment management. Students must implement classes for Items and Characters, demonstrating OOP principles such as inheritance and encapsulation, and include specific methods for character actions and inventory management. The assignment is due on March 16, 2025, and late submissions will follow the course's late policy.

Uploaded by

sametsenturka
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
37 views4 pages

CSE102Spring2025 Assignment1

The CSE 102 Programming Assignment 1 requires students to create a game system in Java that models three character types: Warrior, Mage, and Archer, each with unique inventory and equipment management. Students must implement classes for Items and Characters, demonstrating OOP principles such as inheritance and encapsulation, and include specific methods for character actions and inventory management. The assignment is due on March 16, 2025, and late submissions will follow the course's late policy.

Uploaded by

sametsenturka
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

CSE 102 – Programming Assignment 1 Assignment01 {StudentNumber}.

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]".

2. Character Class (Base Class)

• 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

– inventory and equipment: These fields (arrays of Item) are declared


as protected along with their capacities (e.g., inventoryCapacity,
equipmentCapacity). Derived classes will initialize these arrays with
sizes specific to each character type.
• Methods:
– Character(String name, int health, int attackPower): Ini-
tializes the attributes.
– takeDamage(int damage): Reduces health by the specified damage (en-
suring health remains non-negative) and prints the current health as “Current
Health: X.”
– toString(): Returns a summary such as “Conan [Current Health: 85, Base
Attack: 15].”
– Inventory/Equipment Methods:
* addItemToInventory(Item item): Adds an item to the first avail-
able slot.
* removeItemFromInventory(int index): Removes an item from
a specified index and shifts the array.
* equipItemFromInventory(int invIndex): Transfers an item
from inventory to an available equipment slot.
Example output: “Conan equips Sword of Might from inventory. (Bonus
ATTACK: 5)”.
* unequipItem(int equipIndex): Moves an item from equipment
back to inventory.
Example output: “Merlin removes Mystic Staff from equipment. (Bonus
MANA: 0)”.
3. Derived Classes: Warrior, Mage, and Archer
Note: Each class defines its own uniquely named methods.

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.

Design, Code, and Test


Design: Your program does not require a main() method. You are only responsible for
creating the classes described above (Item, Character, Warrior, Mage, and Archer) in a single
Java file named Assignment01 {StudentNumber}.java. An example of how your
program should operate is provided below.
Code: All Java classes must be included in one file. Your code should be clearly organized
with header comments that explain the purpose of each class and method. Use Java’s standard
libraries (e.g., Math for rounding) if needed; include a comment indicating any such usage.
Test: You are responsible for testing your program. Although you should not submit a main()
method in the final file, you must create your own tests. For example, you can simulate a short
combat scenario where:

a) The Warrior attacks the Mage using warriorAttack().

b) The Mage attacks the Archer using mageAttack().

3
CSE 102 – Programming Assignment 1 Assignment01 {StudentNumber}.java

c) The Archer attacks the Warrior using archerAttack().


After each action, only the current values (e.g., “Current Health: 50”, “Current Armor: 40”,
“Mage’s Remaining Mana: 20”) should be printed. Also, ensure that inventory and equipment
management operations (addition, removal, equipping, unequipping) display concise messages
indicating the affected bonus (e.g., “Conan equips Sword of Might from inventory. (Bonus
ATTACK: 5)”).

Test Case Example

Output Example

You might also like