I am trying to write this class called GradePoint. For some reason I am not seeing why these few variable,which come from an array, are not being seen by the method setGrade. If anyone can tell me why this is happening I would be very pleased. This is a school project that I have out a lot of time into and would like a little help figuring out what is left to do. GradePoint is called by another class. Thanks for the time... here is the code
Thank you Oh Lord<br />For the white blind light<br />A city rises from the sea<br />I had a splitting headache<br />from which the future's made<br />--morrisson
James Chegwidden
Author
Ranch Hand
Joined: Oct 06, 2002
Posts: 201
posted
0
What does setGrade look like?
Mr. C<br /> <br />Author and Instructor<br />My book:<br /><a href="http://www.aw-bc.com/catalog/academic/product/0,1144,1576761614,00.html" target="_blank" rel="nofollow">http://www.aw-bc.com/catalog/academic/product/0,1144,1576761614,00.html</a>
James Chegwidden
Author
Ranch Hand
Joined: Oct 06, 2002
Posts: 201
posted
0
Also, why do you have a method that just creates a Student()? Why not take it out of the method?
James Chegwidden
Author
Ranch Hand
Joined: Oct 06, 2002
Posts: 201
posted
0
Also, would you have to create the Student object first then- create the Array of student objects.
JavaBeginnersFaq "Yesterday is history, tomorrow is a mystery, and today is a gift; that's why they call it the present." Eleanor Roosevelt
Marilyn de Queiroz
Sheriff
Joined: Jul 22, 2000
Posts: 9033
10
posted
0
I'm sorry I haven't had time to look into this for you. Unfortunately, I have a meeting after work today also, so it will be at least another day before I'll be able to try to help.
mike hengst
Ranch Hand
Joined: Oct 19, 2002
Posts: 43
posted
0
For the method that create the Student objects it is one that is required in my specs. setGrade is as follows. It may not be entirely correct either.
It is a little hard to tell what is happening here as atleast two of the arrays are from somewhere else. But this I am able to see: your 'for' loop is assinging different values to the same variables. Which doesn't make much sense to me. So for example 'gradePoints[index]' is being set to a different value each time the loop runs. And will end up containing the value of 'points[i]', where 'i' is '< studentGrades.length'.
Please ignore post, I have no idea what I am talking about.
Another problem is that unless all your arrays are the exact same length, there is a chance you will go out of bounds. In the 'for' loop you are using the length of 'studentGrades' to iterate through 2 others arrays. Not a safe thing to do.
mike hengst
Ranch Hand
Joined: Oct 19, 2002
Posts: 43
posted
0
Originally posted by William Barnes: It is a little hard to tell what is happening here as atleast two of the arrays are from somewhere else. But this I am able to see: your 'for' loop is assinging different values to the same variables. Which doesn't make much sense to me. So for example 'gradePoints[index]' is being set to a different value each time the loop runs. And will end up containing the value of 'points[i]', where 'i' is '< studentGrades.length'.
good point here and I thank you. I had not seen that yet. I put a break; statement in. That should stop the loop when the index of the letterGrade is the same as the gradePoint index. Is that correct? With your second comment. In this case the arrays are the same length throughout. This is just an exercise. Thanks for your time any further comments are appreciated.