I am confuse here that how to make objects here in this scenario.
I am working with IPhone App.
Suppose, I have 2 main entities, STUDENTS and SUBJECTS , now there is many-to-many cardinality here. I have a to keep track of all the marks each student obtained in each subject.
So Database tables becomes 3 like this
STUDENT
SUBJECTS
STUDENTMARKS – (describe the association of student and subject)
Now ERD is clear to me, but I am confuse in OO Modeling here, that what objects/classes I need to make here, and how will they interact?
Please if some one can explain to me.
Thanks in Advance.
Edit:
How can only 2 classes fulfill my requirements? Let me explain:
Class subject contains all properties specifically related to subject, like its name, credit hours, class it is being teached to etc.
Class Student has its own specific properties like name, age, class enrolled in, etc etc.
Now where do I store this information that StudentA obtained 90 marks in SubjectA. As in case of DB I have another table for it, as in m-m relation.
So my question is, Should I also create a class of that 3rd table, say STUDENTMARKS as above , because the main student or subject object cant hold all info like studentA..to…StudentZ is enrolled in SubjectA, and all those student objects contain in Subject Object, but Where to store the marks of each student, because student object can’t have marks attribute, because marks is not directly/only related to student.
Can somebody please make a detailed skitch of classes for this considering Obj-C .
Many to many, Student class will have ArrayList of Subject and Subject will have ArrayList of Student…If you offer particular subject twice in a year than Each Semester object will have Student list in it.
Happy Coding
Welcome to OO World!
After your edition,
You can Have. HashMap of inside Student class as an attribute.
Like
Here Subject is a key and Integer is a marks which student gets. If you want get marks from a srudent object for a spcific subject tha do this,
Where s1 is Student object, subject is Subject class’s object.
Inside Student class you can add method like,
I apologize if indentation is not correct as I am writing this from mobile 😉