Simple Errors

Hey, I’ve just about finished re-writing a program I did a little while ago so that I’ll easily be able to update it and that. The program is pretty much complete, but I’ve run into a few errors which I’m usually able to solve easily but for some reason I just can’t figure out what’s going on with them now. If anyone has a minute to do a quick check-over and see if you can find a fix please do so.

(Pastebin isn’t working for me at the moment, sorry for this wall of code…

import javax.swing.*;
import java.awt.event.*; //Needed for action event listeners for the buttons

public class DnDFormulator
{
	public static void main(String args[])
	{
		Interface tempVariable = new Interface();
	}
}

class Formulator
{
	private int formulaMainAttribute = 0; //Main Attribute - Attack Formula
	private int formulaWeaponRoll= 0; //Weapon Roll - Attack Formula
	private int formulaPassiveBonusAttack = 0; //Passive Bonus - Attack Formula
	private int formulaBaseDamage = 0; //Base Damage - Attack Formula
	private int formulaConstitution = 0; //Constitution - Defence Formula
	private int formulaArmor = 0; //Armor - Defense Formula
	private int formulaPassiveBonusDefence = 0; //Passive Bonus - Defense Formula
	private int formulaSpellDamage = 0; //Spell Damage - Magic Formula
	private int formulaIntellect = 0; //private intellect - Magic Formula
	private int formulaPassiveBonusMagic = 0; //Passive Bonus - Magic Formula
	private int formulaSpellPower = 0; //Spell power - Magic Formula
	private int formulaHealingPower = 0; //Healing Power = Magic Frmula
	private double outputAttackFormula = 0.0; //Attack Formula Output
	private double outputDefenceFormula= 0.0; //Defence Formula Output
	private double outputMagicFormula = 0.0; //Magic Formula Output
	private boolean formulaCriticalStrike = false; //Did you crit?
	
	public Formulator()
	{
	}
	
	//Formulas
	public double attackFormula()
	{
		if ( formulaCriticalStrike == true )
			outputAttackFormula = ( ( ( formulaMainAttribute/ 2 ) + formulaWeaponRoll + formulaPassiveBonusAttack + formulaBaseDamage ) * 2 );
		else
			outputAttackFormula = ( ( formulaMainAttribute/ 2 ) + formulaWeaponRoll + formulaPassiveBonusAttack + formulaBaseDamage);
		
		return outputAttackFormula;
	}
	
	public double defenceFormula()
	{
		if ( formulaCriticalStrike == true )
			outputDefenceFormula = ( ( (formulaConstitution/ 3) + formulaArmor + formulaPassiveBonusDefence ) * 2 );
		else 
			outputDefenceFormula = ( (formulaConstitution / 3) + formulaArmor + formulaPassiveBonusDefence );
		
		return outputDefenceFormula;
	}
	
	public double magicFormula(int formulaSpellOrHealingPower)
	{
		if (formulaSpellOrHealingPower == 0)
			formulaSpellOrHealingPower = formulaHealingPower;
		else
			formulaSpellOrHealingPower = formulaSpellPower;
			
		if ( formulaCriticalStrike == true )
			outputMagicFormula = ( ( ( ( formulaSpellDamage + ( formulaIntellect / 2 ) ) * formulaPassiveBonusMagic ) * ( formulaSpellOrHealingPower / 2 ) ) * 2 );
		else
			outputMagicFormula = ( ( ( formulaSpellDamage + ( formulaIntellect / 2 ) ) * formulaPassiveBonusMagic ) * ( formulaSpellOrHealingPower / 2 ) );
			
		return outputMagicFormula;
	}
	
	//Setters (Doesn't include the outputs because they will be calculated and set within this class)
	public void formulaMainAttributeSetter(int x)
	{
		formulaMainAttribute = x;
	}
	
	public void formulaWeaponRollSetter(int x)
	{
		formulaWeaponRoll = x;
	}
	
	public void formulaPassiveBonusAttackSetter(int x)
	{
		formulaPassiveBonusAttack = x;
	}
	
	public void formulaBaseDamageSetter(int x)
	{
		formulaBaseDamage = x;
	}
	
	public void formulaConstitutionSetter(int x)
	{
		formulaConstitution = x;
	}
	
	public void formulaArmorSetter(int x)
	{
		formulaArmor = x;
	}
	
	public void formulaPassiveBonusDefenceSetter(int x)
	{
		formulaPassiveBonusDefence = x;
	}
	
	public void formulaSpellDamageSetter(int x)
	{
		formulaSpellDamage = x;
	}
	
	public void formulaIntellectSetter(int x)
	{
		formulaIntellect = x;
	}
	
	public void formulaPassiveBonusMagicSetter(int x)
	{
		formulaPassiveBonusMagic = x;
	}
	
	public void formulaSpellPowerSetter(int x)
	{
		formulaSpellPower = x;
	}
	
	public void formulaHealingPowerSetter(int x)
	{
		formulaHealingPower = x;
	}
	
	public void formulaCriticalStrikeSetter(boolean x)
	{
		formulaCriticalStrike = x;
	}
}

class Interface extends JFrame
{
	private JLabel attackFormulaLabelOne = new JLabel("Main Attribute");
	private JLabel attackFormulaLabelTwo = new JLabel("Weapon Roll");
	private JLabel attackFormulaLabelThree = new JLabel("Passive Bonus");
	private JLabel attackFormulaLabelFour = new JLabel("Base Damage");
	private JLabel defenceFormulaLabelOne = new JLabel("Constitution");
	private JLabel defenceFormulaLabelTwo = new JLabel("Armor");
	private JLabel defenceFormulaLabelThree = new JLabel("Passive Bonus");
	private JLabel criticalStrikeLabelOne = new JLabel("Crit?");
	private JLabel magicFormulaLabelOne = new JLabel("Spell Damage");
	private JLabel magicFormulaLabelTwo = new JLabel("Intellect");
	private JLabel magicFormulaLabelThree = new JLabel("Passive Bonus");
	private JLabel magicFormulaLabelFour = new JLabel("Spell Power");
	private JLabel magicFormulaLabelFive = new JLabel("Healing Power");
	private JLabel attackFormulaOutputLabel = new JLabel("AF Output");
	private JLabel defenceFormulaOutputLabel = new JLabel("DF Output");
	private JLabel magicFormulaOutputLabel = new JLabel("MF Output");
	private JLabel attackFormulaCategoryLabel = new JLabel("AF");
	private JLabel defenceFormulaCategoryLabel = new JLabel("DF");
	private JLabel magicFormulaCategoryLabel = new JLabel("MF");
	
	private JTextArea magicFormulaSpellDamage = new JTextArea("", 1, 4);  //String, Rows, Columns
	private JTextArea magicFormulaIntellect = new JTextArea("", 1, 4);
	private JTextArea magicFormulaPassiveBonus = new JTextArea("", 1, 4);
	private JTextArea magicFormulaSpellPower = new JTextArea("", 1, 4);
	private JTextArea magicFormulaHealingPower = new JTextArea("", 1, 4);
	
	private JTextArea attackFormulaOutput = new JTextArea("", 1, 4); //String, Rows, Columns
	private JTextArea defenceFormulaOutput = new JTextArea("", 1, 4); 
	private JTextArea magicFormulaOutput = new JTextArea("", 1, 4);
	
	private JTextArea attackFormulaMainAttribute = new JTextArea("", 1, 4); //String, Rows, Columns
	private JTextArea attackFormulaWeaponRoll = new JTextArea("", 1, 4); 
	private JTextArea attackFormulaPassiveBonus = new JTextArea("", 1, 4); 
	private JTextArea attackFormulaBaseDamage = new JTextArea("", 1, 4); 
			
	private JTextArea defenceFormulaConstitution = new JTextArea("", 1, 4); //String, Rows, Columns
	private JTextArea defenceFormulaArmor = new JTextArea("", 1, 4); 
	private JTextArea defenceFormulaPassiveBonus = new JTextArea("", 1, 4);  
		
	private JRadioButton criticalStrikeTrue = new JRadioButton("True"); //Creates a radio button that says True beside it.
	private JRadioButton criticalStrikeFalse = new JRadioButton("False"); //Creates a radio button that says False beside it.
	
	private int tempInteger = 0;
		
	public Interface()
	{
		setSize(640, 480); //Sets the size of the game window
		setLocationRelativeTo(null); //Centers the window on the users screen.
		setTitle("DnDFormulator"); //Sets the title of the game window
		setDefaultCloseOperation(EXIT_ON_CLOSE); //Basically this makes it so when you hit the red X the window and program will close.
		setResizable(false); //Makes it so that the user cannot resize the JFrame.
		
		
		JPanel formulatorPanel = new JPanel(); //Creates a new JPanel to put everything on.
		getContentPane().add(formulatorPanel);
		
		formulatorPanel.setLayout(null); //Makes it so you can manually positon everything on the JPanel using XY coords.
		
		ButtonGroup criticalButtonGroup = new ButtonGroup(); //Creates a group so that we can group together radio buttons.
		criticalButtonGroup.add(criticalStrikeTrue); //Adds the criticalStrikeTrue radio button to be added to the criticalButtonGroup.
		criticalButtonGroup.add(criticalStrikeFalse); //Adds the criticalStrikeFalse radio button to be added to the criticalButtonGroup.
		criticalStrikeFalse.setSelected(true); //Sets the criticalStrikeFalse radio button to be selected automatically.
		
		JButton calculateButton = new JButton("Calculate!");
		
		formulatorPanel.add(calculateButton);
		
		formulatorPanel.add(attackFormulaMainAttribute);
		formulatorPanel.add(attackFormulaWeaponRoll);
		formulatorPanel.add(attackFormulaPassiveBonus);
		formulatorPanel.add(attackFormulaBaseDamage);
		formulatorPanel.add(defenceFormulaConstitution);
		formulatorPanel.add(defenceFormulaArmor);
		formulatorPanel.add(defenceFormulaPassiveBonus);
		formulatorPanel.add(criticalStrikeTrue);
		formulatorPanel.add(criticalStrikeFalse);
		formulatorPanel.add(magicFormulaSpellDamage);
		formulatorPanel.add(magicFormulaIntellect);
		formulatorPanel.add(magicFormulaPassiveBonus);
		formulatorPanel.add(magicFormulaSpellPower);
		formulatorPanel.add(magicFormulaHealingPower);
		formulatorPanel.add(attackFormulaOutput);
		formulatorPanel.add(defenceFormulaOutput);
		formulatorPanel.add(magicFormulaOutput);
		
		formulatorPanel.add(attackFormulaLabelOne);
		formulatorPanel.add(attackFormulaLabelTwo);
		formulatorPanel.add(attackFormulaLabelThree);
		formulatorPanel.add(attackFormulaLabelFour);
		formulatorPanel.add(defenceFormulaLabelOne);
		formulatorPanel.add(defenceFormulaLabelTwo);
		formulatorPanel.add(defenceFormulaLabelThree);
		formulatorPanel.add(criticalStrikeLabelOne);
		formulatorPanel.add(magicFormulaLabelOne);
		formulatorPanel.add(magicFormulaLabelTwo);
		formulatorPanel.add(magicFormulaLabelThree);
		formulatorPanel.add(magicFormulaLabelFour);
		formulatorPanel.add(magicFormulaLabelFive);
		formulatorPanel.add(attackFormulaOutputLabel);
		formulatorPanel.add(defenceFormulaOutputLabel);
		formulatorPanel.add(magicFormulaOutputLabel);
		formulatorPanel.add(attackFormulaCategoryLabel);
		formulatorPanel.add(defenceFormulaCategoryLabel);
		formulatorPanel.add(magicFormulaCategoryLabel);
		
		attackFormulaMainAttribute.setBounds(50, 50, 50, 20);
		attackFormulaWeaponRoll.setBounds(140, 50, 50, 20);
		attackFormulaPassiveBonus.setBounds(230, 50, 50, 20);
		attackFormulaBaseDamage.setBounds(320, 50, 50, 20);
		
		defenceFormulaConstitution.setBounds(50, 90, 50, 20);
		defenceFormulaArmor.setBounds(140, 90, 50, 20);
		defenceFormulaPassiveBonus.setBounds(230, 90, 50, 20);
		
		criticalStrikeTrue.setBounds(50, 120, 80, 20);
		criticalStrikeFalse.setBounds(130, 120, 80, 20);
		
		magicFormulaSpellDamage.setBounds(50, 160, 50, 20);
		magicFormulaIntellect.setBounds(140, 160, 50, 20);
		magicFormulaPassiveBonus.setBounds(230, 160, 50, 20);
		magicFormulaSpellPower.setBounds(320, 160, 50, 20);
		magicFormulaHealingPower.setBounds(410, 160, 50, 20);
		
		attackFormulaOutput.setBounds(50, 250, 50, 20);
		defenceFormulaOutput.setBounds(140, 250, 50, 20);
		magicFormulaOutput.setBounds(230, 250, 50, 20);
		
		attackFormulaOutput.setEditable(false); //Makes it so that the user cannot type in this JTextArea
		defenceFormulaOutput.setEditable(false);
		magicFormulaOutput.setEditable(false);
		
		attackFormulaMainAttribute.setText("0");
		attackFormulaWeaponRoll.setText("0");
		attackFormulaPassiveBonus.setText("0");
		attackFormulaBaseDamage.setText("0");
		defenceFormulaConstitution.setText("0");
		defenceFormulaArmor.setText("0");
		defenceFormulaPassiveBonus.setText("0");
		magicFormulaSpellDamage.setText("0");
		magicFormulaIntellect.setText("0");
		magicFormulaPassiveBonus.setText("0");
		magicFormulaSpellPower.setText("0");
		magicFormulaHealingPower.setText("0");
		attackFormulaOutput.setText("0");
		defenceFormulaOutput.setText("0");
		magicFormulaOutput.setText("0");
		
		attackFormulaLabelOne.setBounds(50, 30, 100, 20); //X position, Y Position, Length in pixels, Height in pixels.
		attackFormulaLabelTwo.setBounds(140, 30, 100, 20);
		attackFormulaLabelThree.setBounds(230, 30, 100, 20);
		attackFormulaLabelFour.setBounds(320, 30, 100, 20);
		
		defenceFormulaLabelOne.setBounds(50, 70, 100, 20); //X position, Y Position, Length in pixels, Height in pixels.
		defenceFormulaLabelTwo.setBounds(140, 70, 100, 20);
		defenceFormulaLabelThree.setBounds(230, 70, 100, 20);
		
		criticalStrikeLabelOne.setBounds(20, 120, 100, 20); //X position, Y Position, Length in pixels, Height in pixels.
		
		magicFormulaLabelOne.setBounds(50, 140, 100, 20); //X position, Y Position, Length in pixels, Height in pixels.
		magicFormulaLabelTwo.setBounds(140, 140, 100, 20);
		magicFormulaLabelThree.setBounds(230, 140, 100, 20);
		magicFormulaLabelFour.setBounds(320, 140, 100, 20);
		magicFormulaLabelFive.setBounds(410, 140, 100, 20);
		
		attackFormulaOutputLabel.setBounds(50, 230, 100, 20); //X position, Y Position, Length in pixels, Height in pixels.
		defenceFormulaOutputLabel.setBounds(140, 230, 100, 20);
		magicFormulaOutputLabel.setBounds(230, 230, 100, 20);
		
		attackFormulaCategoryLabel.setBounds(30, 50, 100, 20); //X position, Y Position, Length in pixels, Height in pixels.
		defenceFormulaCategoryLabel.setBounds(30, 90, 100, 20);
		magicFormulaCategoryLabel.setBounds(30, 160, 100, 20);
		
		calculateButton.setBounds(50, 400, 100, 20);
		calculateButton.setFocusPainted(false);
		calculateButton.addActionListener(new ActionListener() {  //Action listener for the calculateButton
			public void actionPerformed(ActionEvent e) {
				Formulator tempReference = new Formulator();
				
				String attackFormulaStringOne = attackFormulaMainAttribute.getText();
				String attackformulaStringTwo = attackFormulaWeaponRoll.getText();
				String attackFormulaStringThree = attackFormulaPassiveBonus.getText();
				String attackFormulaStringFour = attackFormulaBaseDamage.getText();
				String defenceFormulaStringOne = defenceFormulaConstitution.getText();
				String defenceFormulaStringTwo = defenceFormulaArmor.getText();
				String defenceFormulaStringThree = defenceFormulaPassiveBonus.getText();
				String magicFormulaStringOne = magicFormulaSpellDamage.getText();
				String magicformulaStringTwo = magicFormulaIntellect.getText();
				String magicFormulaStringThree = magicFormulaPassiveBonus.getText();
				String magicFormulaStringFour = magicFormulaSpellPower.getText();
				String magicFormulaStringFive = magicFormulaHealingPower.getText();
				
				int attackFormulaTempIntOne = Integer.parseInt(attackFormulaStringOne);
				int attackFormulaTempIntTwo = Integer.parseInt(attackFormulaStringTwo);
				int attackFormulaTempIntThree = Integer.parseInt(attackFormulaStringThree);
				int attackFormulaTempIntFour = Integer.parseInt(attackFormulaStringFour);
				int defenceFormulaTempIntOne = Integer.parseInt(defenceFormulaStringOne);
				int defenceFormulaTempIntTwo = Integer.parseInt(defenceFormulaStringTwo);
				int defenceFormulaTempIntThree = Integer.parseInt(defenceFormulaStringThree);
				int magicFormulaTempIntOne = Integer.parseInt(magicFormulaStringOne);
				int magicFormulaTempIntTwo = Integer.parseInt(magicFormulaStringTwo);
				int magicFormulaTempIntThree = Integer.parseInt(magicFormulaStringThree);
				int magicFormulaTempIntFour = Integer.parseInt(magicFormulaStringFour);
				int magicFormulaTempInt = Integer.parseInt(magicFormulaStringFive);
				
				tempReference.formulaMainAttributeSetter(attackFormulaTempIntOne);
				tempReference.formulaWeaponRollSetter(attackFormulaTempIntTwo);
				tempReference.formulaPassiveBonusAttack(attackFormulaTempIntThree);
				tempReference.formulaBaseDamageSetter(attackFormulaTempIntFour);
				tempReference.formulaConstitutionSetter(defenceFormulaTempIntOne);
				tempReference.formulaArmorSetter(defenceFormulaTempIntTwo);
				tempReference.formulaPassiveBonusDefenceSetter(defenceFormulaTempIntThree);
				tempReference.formulaSpellDamageSetter(magicFormulaTempIntOne);
				tempReference.formulaIntellectSetter(magicFormulaTempIntTwo);
				tempReference.formulaPassiveBonusmagicSetter(magicFormulaTempIntThree);
				tempReference.formulaSpellPowerSetter(magicFormulaTempIntFour);
				tempReference.formulaHealingPowerSetter(magicFormulaTempIntFive);
				
				if (criticalStrikeTrue.isSelected() == true)
					tempReference.formulaCriticalStrikeSetter(true);
				else
					tempReference.formulaCriticalStrikeSetter(false);
				
				if  ( (tempReference.formulaSpellPowerSetter = Integer.parseInt(magicFormulaStringFour) ) == 0 )
					tempInteger = 0;
				else
					tempInteger = 1;
				
				//Call the formulas here and infut test into the output
				attackFormulaOutput.setText(""+tempReference.attackFormula()+"");
				defenceFormulaOutput.setText(""+tempReference.defenceFormula()+"");
				magicFormulaOutput.setText(""+tempReference.magicFormula(tempInteger)+"");
			}});
		
		setVisible(true); //Makes the JFrame, also known ass gameWindow visible to the user.
	}
}

You can see the errors here:

Check your capitalization. attackFormulaStringTwo does not exist, you called it attackformulaStringTwo. Same with the others :smiley:

Bleh, thanks a ton. I totally forgot that the spell check in the program I’m using doesn’t care about case…

Below are the things that:
A: Don’t exist :yawn:
B: Might be misspelled? / Don’t exist? :o


magicFormulaTempIntFive /* Doesn't exist */
tempReference.formulaSpellPowerSetter /* Doesn't exist */
tempReference.formulaPassiveBonusmagicSetter /* M needs to be capitalized, it exists */
tempReference.formulaPassiveBonusAttack /* Doesn't exist, similar method name = formulaPassiveBonusAttackSetter */
magicFormulaStringTwo /* Actual variable name's 'F' needs to be capitalized, it exists */
attackFormulaStringTwo /* Actual variable name's 'F' needs to be capitalized, it exists */

All the errors actually fit into 1 Screen-Shot :smiley:

I’d recommend you download Eclipse IDE, or another IDE lol.
Just saying ::slight_smile:

It’s all fixed and working now. I usually notice my spelling errors, that’s how I correct those errors usually; But every once in awhile I totally forget that the spell check in Notepad++ doesn’t care about the case as long as the letters are correct. Thanks for the help.

(Yes, I know I shouldn’t be using Notepad++)

Why do you punish yourself like that :-\

I’m really used to Notepad++ and I find eclipse and netbeans a bit of a pain to get started with since I’d need to devote a few hours to figure them out and learn how packages and that work. Notepad++ just easier, although slightly confusing with 1000 lines of code and multiple classes, to work with for me atm. :wink:

I haven’t done much (any really) swing programming but the amount of variables here is insane. I have some comments below that IMHO will make things somewhat easier.

One thing is that it appears that all of your attributes have either the word Formula or Output in them, with most having Formula. Given that your class is called Formulator, I think you could omit Formula from all of the variable names as it is implied. This will give you fewer places for typos to hit you and will save you some horizontal screen space.

In java, for setters, setXYZ is more common than XYZsetter so your formulaPassiveBonusAttackSetter(45) would become setPassiveBonusAttack(45) (assuming you also remove “Formula” from the name as I suggested.

Probably not the best idea to name a class “Interface”. I know it doesn’t hurt anything but personally I would try to avoid names that are java keywords with different capitalization.

I find your JLabel variables hard to decipher (I have to look at the text set in constructor) and probably makes it easier to make subtle mistakes. For instance, I would change magicFormulaLabelThree to magicPassiveBonusLabel. In general, with this many variables related variables, you need to make things as consistent as possible, such as magicFormulaSpellDamageLabel, magicFormulaSpellDamageTextArea

The comments on your list of private variables are confusing. At first I thought it was indicating that the field was a subtraction between two fields. Your comments contain two parts, a restatement of the variable name and the “Type” of attribute it is. The first part is redundant (it doesn’t give us any additional information) and the format obscures the second part. You could convert it to something like:


// Attack Formula attributes
private int formulaMainAttribute = 0; 
private int formulaWeaponRoll= 0; 
private int formulaPassiveBonusAttack = 0;
private int formulaBaseDamage = 0; 

// Defense Formula attributes
private int formulaConstitution = 0;
private int formulaArmor = 0;
private int formulaPassiveBonusDefence = 0;

// Magic formula attributes
private int formulaSpellDamage = 0;
private int formulaIntellect = 0;
private int formulaPassiveBonusMagic = 0;
private int formulaSpellPower = 0;
private int formulaHealingPower = 0;

// Formula outputs
private double outputAttackFormula = 0.0;
private double outputDefenceFormula= 0.0;
private double outputMagicFormula = 0.0;

// Did you crit?
private boolean formulaCriticalStrike = false;

What I think might be a bigger help is to look at your interface and realize that you are grouping things together by their variable name, when maybe putting them in a class might work better.


public class GUIElement {

   private JLabel label;
   private JTextArea textArea;

   public GUIElement(String labelText, String taText, int taRow, int taColumn) {
        label = new JLabel(labelText);
        textArea = new JTextArea(taText,taRow,taColumn);
   }

   public JLabel getLabel() {
      return label;
   }

  public JTextArea getTextArea() {
      return textArea;
   }

   public void setTextAreaBounds(int a, int , int c, int d) {
      textArea.setBounds(a,b,c,d);
   }
}

Now you can set up your elements like:


GUIElement attackWeaponRoll = new GUIElement("Attack Weapon Roll","",1,4);

// Add the element to the window
formulatorPanel.add(attackWeaponRoll.getTextArea());

and now you know your elements are named consistently. You could then even turn your elements in an array to simplify how you call them:


// Add all of the text areas
for (int i=0; i<guiElements.length; i++) {
   formulatorPanel.add(guiElements[i].getTextArea();
}

Not only is it a whole lot shorter, it also means if you add a new attribute to the array (or remove one) the loop will still work fine.

I never thought twice about the names since I usually know what’s what and what it does, thanks for the tips/information though they should prove to be useful in a little bit. ;D

And yet had to ask for help on a forum for what turned out to be a simple spelling mistake that an IDE would have pointed out right after you typed it. It’s not that we all don’t make silly mistakes from time to time (I do often enough) but it is going to take you soooo much longer to write, update, or debug code like this. It’s ok not to go the IDE route, but it means you have to take on more yourself, and there is a limit to what anyone can hold in their head at one time. Naming consistency and using better abstractions becomes critical.

I’ll have to keep that in mind then, time to go re-write the program! :smiley:

My little tips on variable names,

  • You have same “formula” word as prefix. It wont be useful when you use Eclipse auto-complete (CTRL SPACE). Put it as suffix and short it like attackFrml if needed.
  • “Attack”, “Defense”, etc are pretty common in our mind. You can use “ATK”, “DEF” which shorter and still meaningful.
  • Max 2 capital letters on it.