If you're a noob and don't understand arraylists then set your array to the maximum number of classes that a student can take (instansiating them all to 0) and identify if the value != 0 as you parse through the array.
Don't criticize just because you don't understand
Aziz
Posted: Wed Jul 19, 2006 4:09 pm Post subject: (No subject)
Although, please, for the love of learning, and ease, learn to use ArrayList. There's even a tutorial here on it (if not ArrayList, then Vector, which is similar)
Please, look at the tutorial. Don't stop at what you know. You take on projects not only to make something, but to learn in the process.
wtd
Posted: Wed Jul 19, 2006 6:26 pm Post subject: (No subject)
When you declare a:
code:
ArrayList<Object>
You make baby bunny rabbits cry. Declaring an ArrayList this way throws out all of the benefits generics provide.
OneOffDriveByPoster
Posted: Wed Jul 19, 2006 7:02 pm Post subject: (No subject)
r.3volved wrote:
Don't criticize just because you don't understand
I understand that the program does not need an array. Do you--or do you not--understand?
[Gandalf]
Posted: Wed Jul 19, 2006 7:18 pm Post subject: (No subject)
r.3volved, you originally said array, not ArrayList. That said, I believe OneOffDriveByPoster was pointing out your mistake, ie:
You say: Use an array, avoid hard coded values.
He says: Arrays are hard coded.
The general problem, though, is not what I tried to clear up above. It is that you do not need to store the value of each mark in an array. You can instead just add the mark to the total when it is entered and find the average by dividing the total by the amount of marks. Don't complicate things when you don't need to.
OneOffDriveByPoster
Posted: Wed Jul 19, 2006 7:22 pm Post subject: (No subject)
[Gandalf] wrote:
You can instead just add the mark to the total when it is entered and find the average by dividing the total by the amount of marks. Don't complicate things when you don't need to.
Thank you. Now I think this thread can rest in peace. :D
wtd
Posted: Wed Jul 19, 2006 7:34 pm Post subject: (No subject)
[Gandalf] wrote:
The general problem, though, is not what I tried to clear up above. It is that you do not need to store the value of each mark in an array. You can instead just add the mark to the total when it is entered and find the average by dividing the total by the amount of marks.
Let's put it this way...
Do it both ways. They both have educational value.
Sponsor Sponsor
Aziz
Posted: Thu Jul 20, 2006 7:47 am Post subject: (No subject)
wtd wrote:
When you declare a:
code:
ArrayList<Object>
You make baby bunny rabbits cry. Declaring an ArrayList this way throws out all of the benefits generics provide.
Clarification to avoid confusion: I said <Object> as in <PlaceAnyObjectHere>. I didn't use <E> because most likely that would confuse him. In layman's terms, if you want an array of, say, Strings, it would be ArrayList<String>. Okay, that's it then. I'm done with this topic.