[SOLVED] Problem with class Object
G'day guys,
I have a class setup(ill link all these below and highlight the points im referencing), and after creating an object from that class im having a hell of a time to get the variable names passing to the object.
Example:
I have a class of ''creature'', with the stats strength, defence etc
when i create a new object of that creature(in this case Enemy), its not able to set the statistics of Strength etc. so Enemy.Strength is not valid.
Ive tried get/sets but i must be making a mistake.
As i said, im linking the code below, but ive tried so many different options atm, i wanted to list out what id done first lol.
**CLASS**
Code:
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package gamewithoutaname;
/**
*
* @author Marak
*/
public class skeleton
{
//public Bicycle(int startCadence, int startSpeed, int startGear)
// trying to dec the variables locally to make it easier to pass on the values\
public static String Name = "Skelton";
public static int Strength;
public static int Speed = 2;
public static int Defence = 4;
public static int Hp = 2;
public static int Level = 1;
public static int Experience = 0;
// NOT FREAKING PASSING!
public skeleton(int StartStrength){
Strength = StartStrength;
}
public void setStrength(int newStrength)
{
Strength = newStrength;
}
public void setStr(int Str){
this.Strength = Str;
}
}
**OBJECT CODE**
Code:
public void NewCreature(){
Object Enemy = new skeleton(1);
Enemy.setStrength(5);
}
As you can see (probably) my code gets messier each time i try something new(notibly the setSTR etc).
Ive been at this for a few hours now, each time ive made a little more progress, but its been stuck here for a while, so i've bitten the bullet and decided to ask for help lol
-= marak
EDIT:
Ignore my comments in my code btw :P Thats the stress getting to me haha