This project aims to learn and showcase the application of Java fundamentals and Object-Oriented Programming principles. The medium we chose is a turn-based role-playing game (RPG). There will be one playable character and one NPC (non-playable) enemy.
Refer to the full UML diagram for details. This project follows an objected-oriented design built around modular game components. Classes are separated into files and compartmentalized into different packages.
- Core: The driver class
Mainsetups the game, manages UI/UX (Menus,Scene), and manages game logic throughBattlefieldManagerwhich keeps track and coordinates turns. - Characters: An abstract class
Charactersdefines the blueprint forPlayableCharacterandEnemythat extends this class with its common variables and methods. - Actions:
AbilitywithUsableinterface provide the player with a mechanism for skill use. - Inventory: All
Charactershas oneInventorywhereItemscan be stored, keeping track of capacity and weight. - Item: Many instances of
Itemcan go into oneInventory. All collectable items are stored in Inventories and share a common blueprint. - Weapon: A
Weaponis a generalization of anItemand inherits properties accordingly.Weaponis equipable byCharactersfor use in combat. - Exceptions:
MaxInstanceLimitExceptionis the most important exception to limit instances up to 100 per class. This limit may be shared between super and subclasses. - Unit Testing: Use of JUnit to test relevant classes and to check if exceptions are handled properly.
The design considerations are as follows:
- Emphasis on encapsulation and inheritance for reusability. "DRY" principle and keep things simple.
- Separation of UI/UX and game logic.
- Scalability for adding new characters, abilities, or items.
- Clone the repo:
git clone https://github.com/ray-sjsu/cs-151-fall-2025-project.git
- Open the repo using Intellj IDEA or any IDE of your choice.
- In the project directory, navigate to the file:
src/main/java/rpg/Main/Main.java
- With
Main.javaopened as the active window:
- In Intellj IDEA, click the green Run bottom in the top-left corner.
- In other IDEs, use their respective Run feature to compile and execute the main class.
- Open a command-line terminal and navigate to the source directory:
cd src/main/java
- Compile the Java files recursively to create
.classfiles:
javac rpg/**/*.java
- Run the program using the class name:
java rpg.Main
Follow the terminal prompts and interact with the choices by pressing a number followed by ENTER.
Game ends once either the player or enemy fall.
- Class:
Inventory,Item,Weapon - Interface:
Usable - Exception:
InventoryFullException,MaxInstancesLimitException - Enums:
StatusType,RarityType
- Class:
Ability,Characters,PlayableCharacter,Enemy - Exception:
AbilityOnCooldownException - Enums:
StatType,ActionType
- Class:
BattlefieldManager,TurnAction - UI/UX Class:
Main,Menus,Scene - UML Diagram,
README.md - Unit Testing
Note: Refer to UML diagram. For simplicity, each contributed entry is only listed once.