Create your own character on the CLI. Give your character a name, choose from the various character classes available, and do some actions!
This program is an example on some Java Fundamentals. This includes Basic Syntax, Variables, Data Types, Conditional Statements, Loops, Classes, Methods, and OOP Concepts.
When creating your character, you can choose from three (3) different character classes:
- Saber
- Paladin
- Archer
- Hunter
All character job classes are based off the Jobless
class. However, you cannot assign a character the Jobless
class. It simply serves as a template for its subclasses.
Each job class requires a name and an age for you character. Every character class comes with these methods:
introduce()
: Prints a short sentence stating their name.greeting()
: Prints a short greeting depending on the character's class.getName()
: Returns thename
of the character.getAge()
: Returns theage
of the character.
All subclasses of Jobless
implements one or more of the three (3) available interfaces.
Each interface grants classes access to methods unique to each interface. Some classes implements more than one interface.
Sword
: Grants the class theSlash()
method for its "Attack" action.Shield
: Grants the class theBlock()
method for its "Guard" action. Classes that do not have a shield are unable to utilize the "Guard" action.Gun
: Grants the class theShoot()
method for its "Attack" action.
Note: Current implementation only outputs a line stating the action done.
There are four (4) job classes to choose from:
Saber
: Fights at close-range. Wield theSword
interface granting it access to theSlash()
method.Paladin
: The tank. Wields both theSword
andShield
interfaces, allowing it to both attack with theSlash()
method, and guard withBlock()
method.Archer
: A long-range unit. Unlike its name, this class wields theGun
interface allowing it to attack with theShoot()
method.Hunter
: The one with the most offensive options. Wields both theSword
andGun
interfaces, giving it two (2) attack options:Slash()
andShoot()
.
After character creation, you can make your character perform six (6) actions:
Introduce
: Your character introduces themselves, stating theirname
.Greet
: Your character gives a short greeting. (Based on the class.)Attack
: Your character does an attack! (Based on the class.)Block
: Your character blocks an attack. (OnlyPaladins
can do this.)Info
: Your character's information. It shows theirname
,age
, andjobClass
Leave
: End the program.
To run the program, the following should be first installed:
- Install the requirements specified above.
- Clone or download this repository.
- Open this project in IntelliJ IDEA Community Edition or Ultimate.
- Run the program.
- You will be asked in the beginning if you want to create a character. Typing "Yes" will make you go through with the character creation. Typing "No" or anything else ends the program.
- You will be asked for your character's
name
andage
. Input your character'sname
andage
. - You will be asked to pick a job class for your character. Select from
Saber
,Paladin
,Archer
, andHunter
. Typing any other option results at the program ending and needing to be run again. - Your character creation is now finished! You can now select from six (6) actions.
- Input the action you want your character to do. You will be able to do as many actions as you want.
- If you want to end the program, choose the "Goodbye" option in the action list.
- Implement Picocli
- Add Character Inventory using ArrayList
- More Classes!
- Core Java for the Impatient 3rd Edition by Cay S. Horstmann
- Javatpoint Java Tutorial
- W3schools Java Tutorial
- Abstract Classes and Methods in Java Explained in 7 Minutes by Coding with John
- Java interface 🦅 by Bro Code