I think you can just write some simple getters in your School and
Profile classes, such as

public void getProfile(){
System.out.println("MyProfile: ");
System.out.println(name + " " + age + " " + hobby);
}

Then you can call this method like this:

myPerson.profile.getProfile();

That's the way I did this homework, anyway...

On May 8, 10:48 am, Ewald Ertl <[email protected]> wrote:
> Hello,
>
> On May 7, 10:44 pm, el mio uno y dos <[email protected]> wrote:
>
>
>
> > Hello friends, i have a big problem whit exercise, i think i do every ok, 
> > but i dont know how i can show profile and school. Somebody can help me??? 
> > please
>
> > public class serialization {
> > public static void main(String[] args) {
>
> >   String filename = "MyClassToBePersisited.ser";
> >         if(args.length > 0) {
> >             filename = args[0];
> >         }
> >         Profile profile = new Profile("Alex",31,"Read book");
> >         School school = new School("Eduardo Lobillo",1982);
> >         MyClassToBePersisted myPerson = new MyClassToBePersisted(profile, 
> > school);
>
> >         More code here.......
>
> > ............
>
> > ..........
> >     }
>
> > }
>
> > public class MyClassToBePersisted implements Serializable {
> >     static final long serialVersionUID = -317105593566517899L;
> >     private School school;
> >     private Profile profile;
>
> >     public MyClassToBePersisted(some code here......){
> >         this.profile = profile;
> >         this.school = school;
> >     }
>
> >     public Profile getProfile(){
>
> >        return profile;
>
> >     }
>
> >     public School getSchool(){
> >         return school;
>
> >     }
>
> > }
>
> > public class DeserializeMyClassToBePersisted {
> >      public static void main(String [] args) {
>
> >      Some code here....
>
> > .........
>
> > .......
>
> >      System.out.println("School: " + myPerson.getSchool().toString());      
> >  How can i show this:::??????????
> >      System.out.println("Profile: " + myPerson.getProfile().toString());
>
> Have you overwritten the toString()-method in the classes School and
> Profile, so the data you want is returned, otherwise the toString from
> java.lang.Object is used ( 
> seehttp://java.sun.com/javase/6/docs/api/java/lang/Object.html#toString%...
> )?
>
> HTH
> Ewald

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