Hey everyone!
I was bored so I wanted to put my time to good use and practice Java - exercise the mind a little.
Anyway, on to the good stuff!! ~
I created a project called Adventure. There are 3 classes, Actions, Hero, and Adventure.
Actions - its going to have methods like Open Chest, Moving around, etc.
Hero - creates the heroes starting stats and will control his "Leveling Up" so-to-speak. stat upgrades, etc.
Adventure - the main class of my program. Has public static void main(String []args)
I only just started but I'll show a snippet of what I have.
Only thing I have in Adventure so far.
CODE
public static void main(String[] args)
{
Hero hero = new Hero();
hero.createHero("Jeremy", 1, 40, 6, 3);
}
import java.util.*;
This is what I have of my Hero class so far
CODE
class Hero
{
String name = "Jeremy";
int level;
int HP, Str, Def;
public void createHero(String name, int startLevel, int startHP, int startStr, int startDef)
{
level = startLevel;
HP = startHP;
Str = startStr;
Def = startDef;
}
}
Everything compiles and works so far, but I'm curious what will happen when I want hero to run some methods from the Actions class, or any other class I create?
Since Hero hero = new Hero(); creates an instance of the hero class, can I do a call hero.MethodFromActionsClass(); ??
I'm going to be stuck if that doesnt work. Thank you.
can you please explain to me what is wrong with that if it DOESN'T work?