URGENT TreeMaps - Programmers Heaven

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

URGENT TreeMaps

tollitolli Posts: 44Member
[b][red]This message was edited by tolli at 2007-3-11 4:45:31[/red][/b][hr]
hey guys:

i implemented the class Student and the Class CourseOffering. The class Student creates objects of type student with name, Id number, and GPA.

Class CourseOffering creates objects of type CourseOffering with name of course, Course ID, name of instructor.

In GUI a student can add his information to students.txt and a registrar officer can add a course information to courses.txt.


I need a help in how to do the following:

1. adding (enrolling) students in a course.
2. teachers entering grades for each student per course
3. students their GPA calculated (total of all grades they get on each course).

what other classes to implement?? which should inheret from which?? and do i neet treeMaps for collecting grades? and where to put this map and how to use it???

in other words: we have the following:
* students( SID, FirstName, LastName )
* courses( CID, Teacher, Day, Capacity )
* enrollments( SID, CID ) does this class enrollement inherits from both the above classes????? how to do it!!how to collect grades ???maps?!

please help me

thankssss


Comments

  • zibadianzibadian Posts: 6,349Member
    : [b][red]This message was edited by tolli at 2007-3-11 4:45:31[/red][/b][hr]
    : hey guys:
    :
    : i implemented the class Student and the Class CourseOffering. The class Student creates objects of type student with name, Id number, and GPA.
    :
    : Class CourseOffering creates objects of type CourseOffering with name of course, Course ID, name of instructor.
    :
    : In GUI a student can add his information to students.txt and a registrar officer can add a course information to courses.txt.
    :
    :
    : I need a help in how to do the following:
    :
    : 1. adding (enrolling) students in a course.
    : 2. teachers entering grades for each student per course
    : 3. students their GPA calculated (total of all grades they get on each course).
    :
    : what other classes to implement?? which should inheret from which?? and do i neet treeMaps for collecting grades? and where to put this map and how to use it???
    :
    : in other words: we have the following:
    : * students( SID, FirstName, LastName )
    : * courses( CID, Teacher, Day, Capacity )
    : * enrollments( SID, CID ) does this class enrollement inherits from both the above classes????? how to do it!!how to collect grades ???maps?!
    :
    : please help me
    :
    : thankssss
    :
    :
    :
    The enrollments don't need to inherid from either of them, since you're not extending either the student class or courses. You are trying to link them together.
    I would make a new class, which holds the SID, CID and the grade. Then if you want to know the GPA, you loop through a list of those classes and get the grades of the correct student to perform your calculation.
    If you want to show/process the grades for a certain course, you again loop through the list and collect all the grades matching a certain CID.
    To enter a student into a course, simply create a new element in the enrollments list and set the SID, CID, and grade.
    Here's a small (non-working) example:
    [code]
    public class Enrollment {
    int sid = 0;
    int cid = 0;
    int grade = -1;

    public enrollment(int sid, int cid) {
    this.sid = sid;
    this.cid = cid;
    }
    }

    public class Enrollments extends ArrayList {

    public boolean add(int sid, int cid) {
    // easier to add a new enrollment
    returns add(new Enrollment(sid, cid));
    }

    public Enrollment get(int index) {
    // type-casting to an Enrollment ArrayList
    returns ((Enrollment) super.get(index))
    }

    public double gradeAverage(int sid, int cid) {
    // Calculates the gradeAverage for a course or student
    double result = 0;
    int counter = 0;
    if (sid == -1) { // search a certain cid and keep track of grade/counter
    for (int i = 0; i < size(); i++) {
    if (get(i).cid == cid) {
    result = result + get(i).grade;
    counter++;
    }
    }
    } else { // search a certain sid and keep track of grade/counter
    for (int i = 0; i < size(); i++) {
    if (get(i).sid == sid) {
    result = result + get(i).grade;
    counter++;
    }
    }
    }
    if (counter != 0)
    result = result/counter;
    return result;
    }
    }
    [/code]
Sign In or Register to comment.