File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Beginning Java and the fly likes acceessing an array from another class Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "acceessing an array from another class" Watch "acceessing an array from another class" New topic
Author

acceessing an array from another class

Valarie Brandt
Greenhorn

Joined: Oct 03, 2003
Posts: 24
Hi all I am having a little problem.
I have a class called Student in that class there is a variable:
public final static char[] GRADES = {'A', 'B', 'C', 'D', 'F'};
I have another class called GradePoint Inside of that class I have a method:
public boolean validateGrades(char tempGrade)throws Exception
{
boolean valid = false;
for(int i = 0; i < GRADES.length; ++i)
{
if (tempGrade == GRADES.Student[i])
{
valid = true;
break;
}
}
return valid;
}
The problem I am having is I need to accept user input and the validate the input...but I can't figure out how to get my method in the GradePoint class to use the array from the Student Class.
PS this is the format the instructor wants us to use.
Marilyn de Queiroz
Sheriff

Joined: Jul 22, 2000
Posts: 9046
    
  10
Originally posted by Valarie Brandt:
I have a class called Student in that class there is a variable:

I have another class called GradePoint Inside of that class I have a method:

Code tags are good. Since GRADES is "public final static", it seems that you could use Student.GRADES[0], Student,GRADES[1], etc
[ April 10, 2004: Message edited by: Marilyn de Queiroz ]

JavaBeginnersFaq
"Yesterday is history, tomorrow is a mystery, and today is a gift; that's why they call it the present." Eleanor Roosevelt
Hiep Nguyen
Ranch Hand

Joined: Oct 26, 2001
Posts: 46
i think you can use switch statement for more easy.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: acceessing an array from another class