You can't access the id variable in the Student class from the StudentRecord 
class because it has the protected access qualifier
and you need an instance of the class to call the public getStudentId() method.

Add a myPrint method to the Student class and call that from the main method 
like so:
 studentAnna.myprint();

 print out the members of Student. StudentRecord has it's own myPrint method so 
call that one from 
Student.myPrint();

  public void myPrint()
  {
     System.out.println("id = " + studentId + "\n");
     System.out.println(studentRecord.myPrint());
  }

 That should solve your problem.

 





Date: Sun, 31 Aug 2008 01:52:33 -0400
From: [EMAIL PROTECTED]
To: [email protected]
Subject: [java programming] Help with LAB-1014 Homework

Okay, I am pretty sure that I have done everything that is expected to be done, 
except I am having trouble with the studentId.I need suggestions, help, 
answers, code snip-its; I just need help
Here is what is asked to do in the homework:

1. The homework is to either modify MyStudentRecordExampleProject
NetBeans project you've done in Exercise 1 above or create a new
project
as following.  (You might want to create a new project by copying
the MyStudentRecordExampleProject
project.  You can name the homework project in any way you want
but here I am going to call it MyOwnProject.)

 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 followingCreate 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.
Now here are my three classes:StudentRecordExample: 
http://paste.pocoo.org/show/83963/
Student: http://paste.pocoo.org/show/83964/StudentRecord: 
http://paste.pocoo.org/show/83965/
You will notice in the Student class that the studentId variable is along with 
the set and get methods.You will notice in the StudentRecord class on line 90 
where I want to print the studentId.
Thanks,Stephen






_________________________________________________________________
Get thousands of games on your PC, your mobile phone, and the web with Windows®.
http://clk.atdmt.com/MRT/go/108588800/direct/01/
--~--~---------~--~----~------------~-------~--~----~
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