Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8644267
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T12:15:07+00:00 2026-06-12T12:15:07+00:00

I am in the process of putting together a simple RPG game engine in

  • 0

I am in the process of putting together a simple RPG game engine in java. At this point everything works fine while all my classes are in one directory. Basically, I know I am going to end up with a heap of files and wish to organise them into a package structure. I followed the directions at http://www.jarticles.com/package/package_eng.html but can’t seem to make the magic happen. The two classes posted are the least dependent of the lot and I figure if I can get these working then the rest shouldn’t be a drama. For the record I am using openJDK in Leeenux (remix of Ubuntu netbook Remix)

First class

package adventure.engine;

import java.util.*;

public class Inventory
{
ArrayList itemList = new ArrayList();

public Inventory()
{

}

public void addItem()
{

}

public void removeItem()
{

}
}

And the second:

package adventure.engine;



import adventure.engine.*;



public class PlayerCharacter

{

private String name = "Player";

private String race;

private String plrClass;

private int level;

private int xp;

private int levelXp;

private Inventory inventory = new Inventory();



//---------

//Abilities

//---------



private static final String[] abilitiesList = {"Strength",

                    "Dexterity",

                    "Constitution",

                    "Intelligence",

                    "Wisdom",

                    "Charisma"};



private int[] abilitiesValues = new int[abilitiesList.length];



//------

//Skills

//------

private static final String[] skillsList    = {"Acrobatics"     , "Insight",

                    "Arcana"            , "Intimidate",

                    "Athletics"         , "Nature",

                    "Bluff"         , "Perception",

                    "Diplomacy"     , "Religion",

                    "Dungeoneering"     , "Stealth",

                    "Endurance"     , "Streetwise",

                    "Heal"          , "Thievery",

                    "History"};



private int[] skillsValues = new int[skillsList.length];



//***********

//Constructor

//***********

public PlayerCharacter()

{

    level = 1;

    xp = 0;

    levelXp = 1000;



    setAbility("Strength", 8);

    setAbility("Dexterity", 10);

    setAbility("Constitution", 10);

    setAbility("Intelligence", 10);

    setAbility("Wisdom", 10);

    setAbility("Charisma", 10);

}       //public PlayerSheet()





//*************

//Class Methods

//*************

public void addXp(int val)

{

    xp += val;



    if (xp >= levelXp)

    {

        level++;

        xp -= levelXp;

        //levelXp += ;

    }

}       //public void addXp(int val)





public void updateSkills()

{



}





//Mutators

public void setName(String n)

{

    name = n;

}





public void setLevel(int l)

{

    level = l;

}



public void setRace(String r)

{

    race = r;

}



public void setXP(int x)

{

    xp = x;

}





public void setClass(String c)

{

    plrClass = c;

}



//set ability value by name

public void setAbility(String a, int val)

{

    for(int i = 0; i < abilitiesList.length; i++)

    {

        if(abilitiesList[i].compareTo(a) == 0)

        {

            abilitiesValues[i] = val;

        }

    }

}



//set ability by index

public void setAbility(int index, int val)

{

    abilitiesValues[index] = val;

}



//set skill by name

public void setSkill(String name, int val)

{

    for(int i = 0; i < skillsList.length; i++)

    {

        if(skillsList[i].compareTo(name) == 0)

        {

            skillsValues[i] = val;

        }

    }

}



//set skill by index

public void setSkill(int index, int val)

{

    skillsValues[index] = val;

}



//Accessors

public static String[] getAbilityList()

{

    return abilitiesList;

}



public static String[] getSkillsList()

{

    return skillsList;

}



//retrieve an ability value by name

public int getAbility(String a)

{

    int val = 0;



    for(int i = 0; i < abilitiesList.length; i++)

    {

        if(abilitiesList[i].compareTo(a) == 0)

        {

            val = abilitiesValues[i];

            break;

        }

    }



    return val;

}



//retrieve an ability value by index number

public int getAbility(int i)

{

    return abilitiesValues[i];

}



public int getSkill(String s)

{

    int val = 0;



    for(int i = 0; i < skillsList.length; i++)

    {

        if(skillsList[i].compareTo(s) == 0)

        {

            val = skillsValues[i];

            break;

        }

    }



    return val;

}



public int getSkill(int i)

{

    return skillsValues[i];

}



public String getName()

{

    return name;

}



public String getRace()

{

    return race;

}



public String getPlrClass()

{

    return plrClass;

}



public int getLevel()

{

    return level;

}



public int getXP()

{

    return xp;

}



public int getLevelXP()

{

    return levelXp;

}



}       //public class PlayerCharacter

Classes reside in /home/user/Java/adventure/engine

Output from echo $classpath is /home/james/Java:/.:

when I attempt to compile the second class I get the following error:

PlayerCharacter.java:18: cannot find symbol
symbol  : class Inventory
location: class adventure.engine.PlayerCharacter
    private Inventory inventory = new Inventory();
            ^
PlayerCharacter.java:18: cannot find symbol
symbol  : class Inventory
location: class adventure.engine.PlayerCharacter
private Inventory inventory = new Inventory();

Any feedback on this would be greatly appreciated.How to solve this?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T12:15:08+00:00Added an answer on June 12, 2026 at 12:15 pm

    Two things.

    1) You might not have compiled Inventory
    2) PlayerCharacter and Inventory are in same package. So there is no need to import.

    You should be compiling them as

    javac adventure/engine/Inventory.java

    javac adventure/engine/PlayerCharacter.java

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm in the process of putting together a year long PRACTICAL course (not academic)
I am in the process of putting together a little Android app. I have
I'm in the process of evaluating MongoDB for a personal project. I'm putting together
I am in the process of putting together a shopping cart, I am holding
Im just in the process of putting together the base framework for a multi-tenant
So I'm putting together an RSS parser which will process an RSS feed, filter
How are models and DAOs supposed to interact? I'm in the process of putting
I'm putting together a tool for a colleague which helps to create a nice
So I'm getting into the process of putting some of my first python code
I'm in the middle of putting together a script that manipulates an OmniGraffle document

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.