Pergunta

I am creating a program in java that breaks down every assignment and every point and how it affects your GPA. Im making this for some friends and myself.

First off here is a link to the program so that you can see how it works. (there are still come bugs) http://students.uww.edu/bollesnj07/Program/GPA%20Bot%20v0.4.jar

Here is a visual representation of what im thinking.enter image description here

You can add a profile, then add terms(semesters), then to the terms add courses, and to the courses add assignments.

I want to be able to get, for example, the credits from the profile, and use them to calculate values in the course(or assignments)

What is the best way to achieve this? Right now I have them as subclasses (assignments subclass of course, course subclass of term, term subclass of profile) But I am having difficulty transferring information from class to class. It is possible I am not using superclasses correctly I am fairly new at java, this is my first program outside of school classes.

any help would be greatly appreciated. Thank you.

Foi útil?

Solução

If I'm understanding what you're saying, I think you're confusing the Is-a and Has-a relationships.

A Term Has-a Course(s)

A Course Has-a Assignment(s)

This means that Course does not extend Term, but that Course and Term are independent classes. However, it may be that a Term Is-a ArrayList which Has-a Course.

I don't see any particular need for hierarchy in your class structure.

Outras dicas

assignments subclass of course, course subclass of term, term subclass of profile

That doesn't sound right to me. Courses have Assignments, but Assignments aren't a type of Course themselves. Let's think about what methods they might have:

Course

Teacher getTeacher();
Student[] getStudents();
Date[] getLessonTimes();

Assignment

Teacher getTeacher();
Date getDueDate();
String getTitle();

So though getTeacher() would be applicable to both, most aren't. You could put getTeacher() into a Teachable interface, but everything else indicates they're not really related. Plan out the methods for your other classes and see if there are any duplicates, then based on that decide on your class inheritance.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top