Hi Kristoz

Thank you for your response.

I have tried to figure it out, but no luck.

You mentioned accessing the getter and setter methods and thereafter the 
variables of the OwnStudentRecord class through the instance variable 
ownStudentRecord created in Student.java.  

Can you please give me just one such an example?  I have tried many different 
options, but cannot figure out what it should look like.  

If I use -
ownStudentRecord.getName() {
I get a message that says 'ownStudentRecord package does not exist'  

If I try -
public OwnStudentRecord getName(){
        return name;
    } 
The variable 'name' (in the OwnStudentRecord class) cannot be found

If I try -
public OwnStudentRecord getName(){
        return ownStudentRecord.   ;
the dot operator after ownStudentRecord only gives me access to the getter and 
setter methods of the OwnStudentRecord class and not to any of its variables.


Below is my latest attempt, but I still get a 'null' return.


Student.java:

public OwnStudentRecord getOwnStudentRecord() {
        return ownStudentRecord;
        
    }
    public void setOwnStudentRecord(String name, double mathGrade, 
            double englishGrade, double scienceGrade) {
        this.ownStudentRecord = ownStudentRecord;
            
    }    


Main Method:

student1.setOwnStudentRecord("Rene", 60, 70, 80);

 System.out.println(
                "Student Name = " + student1.getOwnStudentRecord()); 


Thanks


Kind regards
 
Rene Erwee

 
-----Original Message-----
From: [email protected] [mailto:[EMAIL PROTECTED] On 
Behalf Of Kristoz
Sent: 01 October 2008 04:15 PM
To: Free Java Programming Online Training Course By Sang Shin
Subject: [java programming] Re: LAB 1014 - CREATE YOUR OWN CLASS HOMEWORK


Hi Rene,

The object of the homework is to declare the StudentRecord as an
instance variable, not be a superclass of Student.

Just declare it like any instance variable:

private StudentRecord studentRecord;

Then use its getter and setter methods to access its variables from
within Student.

Rgds Kristoz

On Oct 1, 3:39 am, "Rene Erwee" <[EMAIL PROTECTED]> wrote:
> Hi
>
> I do not think that I have done this homework assignment in the way it
> was meant to be done.  I have coded Student class to extend my
> StudentRecord class and was able to use the code below in my main method
> to get the correct result.  The homework assignment does not explicitly
> say that we should make Student class extend StudentRecord class, so I
> am sure there is a different way in which we are supposed to get the end
> result.  I just cannot figure out how.  I think it has something to do
> with the fact that Student class should have StudentRecord class as an
> instance variable and that somehow this must be used in the main method,
> but how?
>
> Can anybody please advise me?
>
> Extract from main method:
>
> Student student1 = new Student("Rene Erwee",77,85,90,700411014);
>
> System.out.println(
>
>                 "Student Name = " + student1.getName() + " , " +
> "Student Id = " +
>
>                 student1.getStudentId() + " , " + "Student Average = " +
>
>                 student1.getAverage());
>
> Thanks
>
> Kind regards
>
> Rene Erwee





--~--~---------~--~----~------------~-------~--~----~
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