Need help with Logic Error(I think?)
Hello. The following is a program I am creating to calculate the start value of a gymnastics routine, the basics are as follows(And not everything is implemented yet):
In gymnastics there are the aparatuses, then skill group codes, then "skills" a-g or something like that(My brother is the gymnast, i'm the programmer). Basically as of right now im testing the logic of actually adding up the values based on which option they choose, since the options are strings, i set the strings into an array and then i have a score value array(Values are random at this point).
The problem is, the totalvalue(i think its called that) number is not showing up. There is something wrong in the way i order the things.
This compiles PERFECTLY and runs, and everything is right except the showing up of a number which should show when you choose options in the combo boxes.
Here is the code, help please :)!!!
Main:
//
//GymnasticsMain.java
//The Main top program - calls the panels.
//By: Ian Coolidge
//June 5, 2007
//
import javax.swing.*;
publicclass GymnasticsMain
{
//Calls all the panels, they can be found under their names
publicstaticvoid main (String[] args)
{
JFrame frame =new JFrame ("Gymnastics Super Program");
frame.setDefaultCloseOperation (JFrame.EXIT_ON_CLOSE);
GymnasticsControls controlPanel =new GymnasticsControls();
frame.getContentPane().add(controlPanel);
frame.pack();
frame.setVisible(true);
}
}
The Guts of the program:
//--
//GymnasticsCrontrols.java
//This creates the actual guts of the program, you know, the buttons and menus and the such
//By: Ian Coolidge
//June 5, 2007
//--
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import java.applet.AudioClip;
import java.net.URL;
import java.lang.*;
publicclass GymnasticsControlsextends JPanel
{
private JComboBox GymApparatus;
private JComboBox GymGroupCode;
private JLabel label;
private JLabel scoreLabel;
privatedouble currentApparatus;
privatedouble currentCode;
private String ScoreLine;
privatedouble TotalValue;
privatedouble[] score =newdouble[20];
public GymnasticsControls()
{
score[0] = 1.2;
score[1] = 1.4;
score[2] = 0.5;
score[3] = 0.2;
score[4] = 2.2;
score[5] = 0.7;
score[6] = 0.2;
score[7] = 0.2;
score[8] = 6.2;
score[9] = 3.2;
score[10] = 2.2;
score[11] = 0.76;
score[12] = 0.378;
score[13] = 0.87;
score[14] = 0.19784;
score[15] = 0.1278;
score[16] = 0.2834;
score[17] = 0.3534;
score[18] = 0.323;
score[19] = 0.45;
ScoreLine ="Your starting value is: "+TotalValue;
scoreLabel =new JLabel(ScoreLine);
//The following is the declaration of the list of options in the drop down menus
String[] Apparatus ={"Apparatus","Floor","Pommel","Vault","Rings","PBars","High Bar"};
GymApparatus =new JComboBox (Apparatus);
GymApparatus.setAlignmentX (Component.LEFT_ALIGNMENT);
String[] GroupCode ={"Group Code","I","II","III","IV","V"};
GymGroupCode =new JComboBox (GroupCode);
GymGroupCode.setAlignmentX (Component.LEFT_ALIGNMENT);
//Sets up the panel
add (scoreLabel);
setPreferredSize (new Dimension (300, 100));
setBackground (Color.cyan);
setLayout (new BoxLayout (this, BoxLayout.Y_AXIS));
add (Box.createRigidArea (new Dimension(0,5)));
add (GymApparatus);
add (Box.createRigidArea (new Dimension(0,5)));
add (GymGroupCode);
add (Box.createRigidArea (new Dimension(0,5)));
GymApparatus.addActionListener (new ComboListener());
GymGroupCode.addActionListener (new ComboListener());
TotalValue = currentApparatus + currentCode;
}
privateclass ComboListenerimplements ActionListener
{
publicvoid actionPerformed (ActionEvent event)
{
//Should assign a number based on the number string to whatever is chosen in the drop down menu
currentApparatus = score[GymApparatus.getSelectedIndex()];
currentCode = score[GymGroupCode.getSelectedIndex()];
}
}
}
I tried moving stuff all around, and it still doesn't work. Thanks very much for all the help!
-Ian

