Help displaying an array from a seperate class
Okay, What I'm trying to do is take data from an array in my main class, and display it in a different class.
here is my main class:
Code:
public class CharCreate
{
public static void main(String args[])throws Exception
{
int AddSkillPoints = 5;
int[] dials = new int[5];
dials[0] = 5;
dials[1] = 5;
dials[2] = 5;
dials[3] = 5;
dials[4] = 5;
char Input;
System.out.println("-----");
System.out.println("");
System.out.println("Press 1 to assign skill points");
System.out.println("");
System.out.println("-----");
do{
Input = (char) System.in.read();
if(Input == '1')
{
System.out.println("-----");
System.out.println("");
System.out.println("Press A to add 1 point to Dialouge. Current Dialouge points: " + dials[0]);
System.out.println("");
System.out.println("Press B to add 1 point to Intellegince. Current Intellegince points:" + dials[1]);
System.out.println("");
System.out.println("Press C to add 1 point to Agility. Current Agility points: " + dials[2]);
System.out.println("");
System.out.println("Press D to add 1 point to Luck. Current Luck points: " + dials[3]);
System.out.println("");
System.out.println("Press E to add 1 point to Strength. Current Strength points: " + dials[4]);
System.out.println("");
System.out.println("Unassigned points remaining: " + AddSkillPoints);
System.out.println("");
System.out.println("-----");
}
else if(Input == 'A')
{
dials[0] = dials[0] + 1;
AddSkillPoints = AddSkillPoints - 1;
System.out.println("-----");
System.out.println("");
System.out.println("Press A to add 1 point to Dialouge. Current Dialouge points: " + dials[0]);
System.out.println("");
System.out.println("Press B to add 1 point to Intellegince. Current Intellegince points:" + dials[1]);
System.out.println("");
System.out.println("Press C to add 1 point to Agility. Current Agility points: " + dials[2]);
System.out.println("");
System.out.println("Press D to add 1 point to Luck. Current Luck points: " + dials[3]);
System.out.println("");
System.out.println("Press E to add 1 point to Strength. Current Strength points: " + dials[4]);
System.out.println("");
System.out.println("Unassigned points remaining: " + AddSkillPoints);
System.out.println("");
System.out.println("-----");
}
else if(Input == 'B')
{
dials[1] = dials[1] + 1;
AddSkillPoints = AddSkillPoints - 1;
System.out.println("-----");
System.out.println("");
System.out.println("Press A to add 1 point to Dialouge. Current Dialouge points: " + dials[0]);
System.out.println("");
System.out.println("Press B to add 1 point to Intellegince. Current Intellegince points:" + dials[1]);
System.out.println("");
System.out.println("Press C to add 1 point to Agility. Current Agility points: " + dials[2]);
System.out.println("");
System.out.println("Press D to add 1 point to Luck. Current Luck points: " + dials[3]);
System.out.println("");
System.out.println("Press E to add 1 point to Strength. Current Strength points: " + dials[4]);
System.out.println("");
System.out.println("Unassigned points remaining: " + AddSkillPoints);
System.out.println("");
System.out.println("-----");
}
else if(Input == 'C')
{
dials[2] = dials[2] + 1;
AddSkillPoints = AddSkillPoints - 1;
System.out.println("-----");
System.out.println("");
System.out.println("Press A to add 1 point to Dialouge. Current Dialouge points: " + dials[0]);
System.out.println("");
System.out.println("Press B to add 1 point to Intellegince. Current Intellegince points:" + dials[1]);
System.out.println("");
System.out.println("Press C to add 1 point to Agility. Current Agility points: " + dials[2]);
System.out.println("");
System.out.println("Press D to add 1 point to Luck. Current Luck points: " + dials[3]);
System.out.println("");
System.out.println("Press E to add 1 point to Strength. Current Strength points: " + dials[4]);
System.out.println("");
System.out.println("Unassigned points remaining: " + AddSkillPoints);
System.out.println("");
System.out.println("-----");
}
else if(Input == 'D')
{
dials[3] = dials[3] + 1;
AddSkillPoints = AddSkillPoints - 1;
System.out.println("-----");
System.out.println("");
System.out.println("Press A to add 1 point to Dialouge. Current Dialouge points: " + dials[0]);
System.out.println("");
System.out.println("Press B to add 1 point to Intellegince. Current Intellegince points:" + dials[1]);
System.out.println("");
System.out.println("Press C to add 1 point to Agility. Current Agility points: " + dials[2]);
System.out.println("");
System.out.println("Press D to add 1 point to Luck. Current Luck points: " + dials[3]);
System.out.println("");
System.out.println("Press E to add 1 point to Strength. Current Strength points: " + dials[4]);
System.out.println("");
System.out.println("Unassigned points remaining: " + AddSkillPoints);
System.out.println("");
System.out.println("-----");
}
else if(Input == 'E')
{
dials[4] = dials[4] + 1;
AddSkillPoints = AddSkillPoints - 1;
System.out.println("-----");
System.out.println("");
System.out.println("Press A to add 1 point to Dialouge. Current Dialouge points: " + dials[0]);
System.out.println("");
System.out.println("Press B to add 1 point to Intellegince. Current Intellegince points:" + dials[1]);
System.out.println("");
System.out.println("Press C to add 1 point to Agility. Current Agility points: " + dials[2]);
System.out.println("");
System.out.println("Press D to add 1 point to Luck. Current Luck points: " + dials[3]);
System.out.println("");
System.out.println("Press E to add 1 point to Strength. Current Strength points: " + dials[4]);
System.out.println("");
System.out.println("Unassigned points remaining: " + AddSkillPoints);
System.out.println("");
System.out.println("-----");
}
if(AddSkillPoints == 0)
{
Review Review = new Review();
}
}while(Input != '*');
}
}
and the other class
Code:
public class Review
{
public static void Review(String args[])throws Exception
{
char Input;
System.out.println("-----");
System.out.println("");
System.out.println("Your Final Skill levels are:");
System.out.println("");
System.out.println("Dialouge: " + CharCreate.dials[0]);
System.out.println("");
System.out.println("Intellegince: " + CharCreate.dials[1]);
System.out.println("");
System.out.println("Agility: " + CharCreate.dials[2]);
System.out.println("");
System.out.println("Luck: " + CharCreate.dials[3]);
System.out.println("");
System.out.println("Strength: " + CharCreate.dials[4]);
System.out.println("");
System.out.println("---");
System.out.println("");
System.out.println("Are you happy with these results?");
System.out.println("");
System.out.println("A. Yes");
System.out.println("");
System.out.println("B. No");
System.out.println("");
System.out.println("-----");
do{
Input = (char)System.in.read();
if(Input == 'A')
{
System.out.println("Done");
}
else if(Input == 'B')
{
CharCreate CharCreate = new CharCreate();
}
}while(Input != '*');
}
}
I want to take the array "dials" from the main class and display it in the "Review" class.
When I compile "CharCreate.dials[]" " get a message saying "cannont find variable dials"
What is the correct syntax for this?