Ok, so I was having this weird issue, which is what the following rambling is all about, however I fixed my problem, but it brings up a new question, plus I thought I'd post this since someone else might have a problem with this. So if you like, you can read the following post, to get some context, and my question is after.
So I'm trying to split up my code into manageable pieces, because I'm trying to do a tetris implementation of oo-game-design by Britt L. Hannah, which is a bit of a mindf**k
sorry for not giving a link, first post restrictions and all. All you need to know is that action, and entity, are base classes.
anyways, I make tabs for action and entity objects. Now, actions take entities in their constructor, and entities take actions in a few of their methods. I didn't expect ordering to be an issue, because I have some old code in front of me of the form
Code:
tab 1: "A_PIXEL"
class pixel{
…
pixel(…, charge Q){
…
}
…
}
Tab 2: C_CHARGE
class charge{
…
charge(…){
…
}
}
which runs fine.
however this
Code:
tab 1:"b_Actions"
String ROTATE="Rotate";
String DESCEND="Descend";
class Action extends NonRenderableObject{
//run, jump, shoot, accelerate, explode, etc.
//Action objects are invoked by Entity objects, and can affect other Entity objects.
Action(){
}
void doAction(){
}
}
class Rotate{
Rotate(Entity entity){
}
}
tab2: "c_entity"
class Entity extends NonRenderableObject{
//This represents a game token. It can be anything that exists in game
Entity(){
}
//Assigns a State to Entity
void assignState(State state, String stateName){
}
//Assigns an Action to Entity
void assignAction(Action action, String actionName){
}
//Asks for State if it exists; returns null if no state exists
State hasState(String stateName){
State S=new State();
return S;
}
//Activates the action
void activateAction(String actionName){
}
//Deactivates the action
void deactivateAction(String actionName){
}
//do each active action
void doActions(){
}
}
does not. I get the error
'Cannot find a class or type named "Entity"'
I've labeled the tabs that way to control the order of their appearance. The reason for this is; if I remove "Entity entity" from the rotate constructor, then the code runs fine, but then if I change the order of the tabs by changing the alphabetical ordering of the tab names, the code does not run, and I get the error
'Cannot find a class or type named "Action"'
This suggests to me that it can't find the class because it is defined in the tab following it. But if that were the case, my other code should not run.
Anyways, I realized the problem is that my code didn't have a setup() function in it. But my question now is, why does not having setup in your code do this?