-1

Im having trouble trying to work out what data structure to use for an assignment .

I have a main program and a Student class . The main program using Scanner to get input from the user that asks for 1. Number, 2 Last Name, 3 First Name, 4 Number of Subjects they want to enter data for. --- up until this point im fine - i create the student object using this info (in the constructor) and place it in a vector in the main program. All fine up to here --- it then goes on to ask for the subject number (from a menu I display) , the number of assignments to enter for that subject, then the homework marks and the exam marks for each assignment. This is where im having trouble. The way im trying is to create a method in the Student class that add to an arraylist - using a seperate method and arraylist for each piece of data (i.e. one for the subject numbers, one for the number of assignments, on for HW marks, one for ex Mark. The reason im doing this is my previous code (before I had a student class and vector) I simply used arrays in the main code to store these before printing out to screen and my program logic is designed around this. I can see though that it is probably not the best way and will get complicated for trying to get this info back and using it in the right order. I think I need some other way to store it , probably using a single data structure that will somehow hold the number of subjects, the subjects numbers, how many assignments each subject has and the hw and ex marks for each subject. So my questions is , what data structure would be best suited to this , that I can use in my class ,update with a method and easily read back in the data. I am just asking for suggestions I can research please and not any code as it is an assignment. Bearing in mind im a beginner and wont be connecting to a DB or anything , just something like arraylists, vectors etc (although i dont think they are suitable - but i might be wrong)

thanks

boliviab
  • 83
  • 2
  • 14
  • As per this [question](http://stackoverflow.com/questions/1386275/why-is-java-vector-class-considered-obsolete-or-deprecated) Vector is considered "obsoleted", use ArrayList instead. – xav Mar 11 '14 at 23:51
  • its not obsolete for me as it is part of my coursework to use vectors. Im well aware vectors are outdated and have been replaced but if im required to use them for coursework then obviously they are very relevant for me. Also if you read the question I do state I am trying to use arraylists in regards the problem im having (yes im using a vector but that part of the program is functioning perfectly for me and Im not askgin for help in that area). – boliviab Mar 11 '14 at 23:57
  • ok, fine! maybe your teacher is more obsolete than `Vector` then ;) – xav Mar 12 '14 at 00:02

1 Answers1

0

How about specialized classes? For example Subject

blueygh2
  • 1,538
  • 10
  • 15
  • not sure how that would work - are you able to elaborate a little please? – boliviab Mar 11 '14 at 23:48
  • If you know that you will have a Subject that will have a number and Assignments, you can create a class Subject that holds this information, and your Student class contains a Subject object – blueygh2 Mar 11 '14 at 23:50
  • think im getting what you mean. I actually dont KNOW that a certain subject will be chosen , but I knwo there will be at least one subject input. So if I create some form of class that I can create an object for for each result/subject , that is stored within a student object.Not thought of doing that and gives me another avenue to think about thanks. – boliviab Mar 11 '14 at 23:54