So, I'm still pretty fresh at programming. In Netbeans, the name of the project is cardgame_rewrite. My main application file is such
Code:
/*
* Cardgame_rewriteApp.java
*/
package cardgame_rewrite;
import org.jdesktop.application.Application;
import org.jdesktop.application.SingleFrameApplication;
/**
* The main class of the application.
*/
public class Cardgame_rewriteApp extends SingleFrameApplication {
/**
* At startup create and show the main frame of the application.
*/
@Override protected void startup() {
show(new Cardgame_rewriteView(this));
}
/**
* This method is to initialize the specified window by injecting resources.
* Windows shown in our application come fully initialized from the GUI
* builder, so this additional configuration is not needed.
*/
@Override protected void configureWindow(java.awt.Window root) {
}
/**
* A convenient static getter for the application instance.
* @return the instance of Cardgame_rewriteApp
*/
public static Cardgame_rewriteApp getApplication() {
return Application.getInstance(Cardgame_rewriteApp.class);
}
/**
* Main method launching the application.
*/
public static void main(String[] args) {
launch(Cardgame_rewriteApp.class, args);
Player player1 = new Player();
Player player2 = new Player();
Turn CurrentTurn;
CurrentTurn = new Turn();
player1.theTurn = CurrentTurn;
player2.theTurn = CurrentTurn;
while (player1.life > 0 && player2.life > 0)
{
while (player1.movesLeft > 0)
{
CurrentTurn.currentPlayer = player1;
}
player1.movesLeft = 5;
while (player2.movesLeft > 0)
{
CurrentTurn.currentPlayer = player2;
}
player2.movesLeft = 5;
}
}
}
The class Turn has an int member called direc.
As you can see above, I've declared a Turn object called CurrentTurn.
In my GUI file, I'm trying to create a method of action when the user clicks a button, the value of CurrentObject.direc is set to 12.
Code:
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
CurrentTurn.direc=12;
}
However, the program keeps giving warnings as if CurrentTurn didn't exist.
Is this a scope problem, or a problem with public/private variables? I've declared both the Turn class and its member variables as public.