This project is an implementation of an Alchemy and Forging Game based on the provided UML diagram. It involves implementing various classes and interfaces to create items, perform merging, and manage energy and charges. The problem was introduced by Sir Jomari Joseph Barera.
To use this game, follow the instructions below:
-
Clone the repository to your local machine.
git clone https://github.com/your-username/alchemy-forging-game.git
Replace
your-username
with your GitHub username. -
Import the necessary libraries and classes into your project.
-
Implement the required classes and interfaces based on the provided UML diagram and instructions.
-
Use the implemented classes and interfaces to create items, perform merging, and manage energy and charges within your game.
Implement the Item
abstract class according to the provided UML diagram.
-
Declare the
numberOfItems
as a static variable with a default value of 0. -
Declare the remaining attributes of the abstract class
Item
according to the UML. -
Implement the constructor for the
Item
class:- Assign the
id
attribute with the current value ofnumberOfItems
, then increment the value ofnumberOfItems
variable. - Initialize the
value
,name
, andweight
attributes using their corresponding parameters.
- Assign the
-
Declare the abstract method
use
according to the UML specification. -
Implement the getters and setters according to the UML specification.
-
Override the
compareByValue
method from theItemComparable
interface by returning the difference between the value of the current item and the parameteri
. -
Override the
compareByWeight
method from theItemComparable
interface by returning:- 1 if the weight of the current item is greater than the weight of item
i
. - -1 if the weight of the current item is less than the weight of item
i
. - 0 if the weight of the current item is equal to the weight of item
i
.
- 1 if the weight of the current item is greater than the weight of item
Implement the Consumable
abstract class according to the provided UML diagram.
-
Declare the attributes of the abstract class
Consumable
according to the UML. -
Implement the constructor for the
Consumable
class:- Call the constructor of the superclass to initialize the
name
,value
, andweight
based on the corresponding parameters. - Initialize the
spoiled
attribute with its corresponding parameter. - Initialize the
consumed
attribute with a default value offalse
.
- Call the constructor of the superclass to initialize the
-
Implement the getters and setters according to the UML specification.
Implement the EnergyBall
class according to the provided UML diagram.
-
Declare the attributes of the class
EnergyBall
according to the UML. -
Implement the constructor for the
EnergyBall
class:- Call the constructor of the superclass to initialize the
name
with "energy ball",value
of 0,weight
of 10, andspoiled
byfalse
. - Initialize the
capacity
attribute with its corresponding parameter. - Initialize the
energy
attribute with a default value of 0.
- Call the constructor of the superclass to initialize the
-
Implement the
releaseEnergy
method:- Return the current value of the energy and set the energy to 0.
-
Override the
charge
method from theChargeable
interface:- Increase the energy by 1 if the current energy is less than the capacity.
- Print the statement "This energy ball is fully charged." if the current energy is equal to or greater than the capacity.
-
Override the
use
method from theItem
abstract class:- Print the statement "This energy ball can't be used in this situation."
Implement the ItemComparable
interface according to the provided UML diagram.
No implementation details are provided for this interface. It serves as a guide for classes that need to implement comparison methods based on item value and weight.
Implement the Mergeable
interface according to the provided UML diagram.
No implementation details are provided for this interface. It serves as a guide for classes that need to implement merging functionality.
Implement the Chargeable
interface according to the provided UML diagram.
No implementation details are provided for this interface. It serves as a guide for classes that need to implement charge-related functionality.
Please note that the specific code implementation for each class is not provided here. The provided instructions guide you on how to implement the classes based on the UML diagram and the desired behavior described in the instructions.
The following classes are included in this repository:
-
Sword: This class represents a sword item in the game. It provides methods for attacking and handling sword-specific functionalities.
-
Dagger: The Dagger class represents a dagger item. It contains methods for close-range attacks and dagger-specific actions.
-
Staff: The Staff class represents a magical staff used in the game. It includes methods for casting spells and performing staff-related actions.
-
Bow: This class represents a bow item. It provides functionality for long-range attacks and bow-related actions.
-
Potion: The Potion class represents a healing potion in the game. It contains methods for consuming the potion and healing the player.
-
Mergeable: The Mergeable interface represents an item that can be merged with other items. It provides methods for merging and handling mergeable items.
If you would like to contribute to this project, please follow these steps:
-
Fork the repository by clicking the "Fork" button on the top right corner of this page. This will create a copy of the repository in your GitHub account.
-
Clone the forked repository to your local machine.
git clone https://github.com/your-username/alchemy-forging-game.git
Replace
your-username
with your GitHub username. -
Create a new branch for your changes. Use a descriptive name related to the feature or fix you are working on.
git checkout -b feature/my-feature
-
Implement your changes, following the provided UML diagram and instructions.
-
Commit your changes with a descriptive commit message.
git commit -m "Add feature or fix"
-
Push your changes to your forked repository.
git push origin feature/my-feature
-
Open a pull request from your forked repository to the original repository. Provide a clear description of your changes and why they should be merged.
Once your pull request is reviewed and approved, it will be merged into the main project.
This problem was introduced by Sir Jomari Joseph Barera, an instructor at VSU (Visayas State University). We acknowledge his contribution in presenting this problem for implementation.