On Feb 13, 7:04 pm, Cecil Haertel III <[email protected]> wrote:
> Is the following a mis-type.
>
>    - Create a Student class as following:
>       - The Student class has StudentRecord class as an instance variable.
>       Name it as studentRecord.
>          - You can use the StudentRecord class from the
>          MyStudentRecordExampleProject above or you can create a new
> one - the only
>          requirement is that it has to have at least one instance
> variable of its
>          own.
>          - The Student class has studentId instance variable whose type is
>       Integer type.
>       - Move the studentCount static variable from the StudentRecord class
>       to Student class.
>
>    - Rewrite main.java as following
>       - Create 3 instances of Student class and initialize them accordingly
>       - use whatever initialization values that  are appropriate.
>       - Display the information of each student including the student id,
>       name.
>       - Display the studentCount.
>
> If not why would we introduce another class into this project.
>
> If so I'm a bit confused?

No it is not mistyping.
You may use the search button to search for 1014, there are a number
of posts about this exercise.

The purpose here is to separate as much as possible the various
tasks.

1 - Main creates 3 Students and print their info, just that, you
don't
need to do anything else in main.

That means you need a line as follows:
Student foo = new Student(...);
and a line as follows:
foo.printInfo();

Do you see what I mean? The bare requirement.

2 - In Student, you need the constructor and the printInfo() method,
plus
various getters and setters, and a few private variables, just that
nothing else.

Here you'll construct the students with the parameters from main().
So
think about it, which parameters are needed?

Basically Student just serves as a data receiver/provider, just that.

3 - In StudentRecord, you need a constructor with parameters (to be
able
to call it from the Student constructor), various getters and
setters,
and the getAverage() method, just that.
StudentRecord just serves as a computational unit.
If you think of the problem this way, you'll find soon the advantages
of separated classes.

And finally for the student count, a static variable should use the
class to call it, so something like:
FooClass.method()
would do it.

-- 
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/javaprogrammingwithpassion?hl=en

Reply via email to