On Mar 19, 5:37 am, Rafał Laczek <[email protected]> wrote:
> Person class extends AddressImpl class and it has now following
> constructor and method.
>
> AddressInterface address;
>     // Constructor with arguments
>     Person( int streetNumber,
>     String streetName,
>     String country,
>     AddressInterface address){
>         super(streetNumber, streetName,country);
>         this.address=address;
>     }
>
>    //Implementation of the method
>  public AddressInterface getAddress(){
>      return address;
>     }
>
> }
>
> I have also created Person object in Main but there s a problem to
> initialize it with data.
> Person person1 = new Person(10, "Java Street", "Korea");
>
> In constructor we have theoretically 4 parameters and I have passed 3
>
> What I should to do here?
In main:
// Create an address first, then pass it to person constructor.
Person person1 = new Person(10, "Java Street", "Korea", address);

Please note Laini suggested a better solution. Moreover there is
another thread by Ahmet with same issue as yours, he has fixed the
problem. You might want to take a look.
>
> Thank you for reply
>
> Best regards,
>
> Dnia 18-03-2009 o godz. 14:29 Min napisał(a):
>
> > On Mar 18, 6:22 pm, Rafał Laczek <[email protected]> wrote:
> > > Hello Fiends,
>
> > > In my homework Person class extends AddressImpl and implemnts
> > > MyOwnInterface
> > > I have created constructor according to arguments in this class and
> > > AddressImpl one.
>
> > > I have a problem with implementation of public AddressInterface
> > > getAddress(){
> > >      return ....????
>
> > > }
> > I do not approach this the way you do. Anyway:
> > // Your person extended addressImpl. Try to return the parent:
> > public AddressInterface getAddress(){
> >  return super;
> > }
>
> > > Should this method return all following methods?
> > > public int getStreetNumber()
> > > public String getStreetName()
> > > public String getCountry()
>
> > > Thank you in advance for your help!
>
> > > Best regards,
> > > Rafał Laczek
>
> > > ----------------------------------------------------
> > > Zło zrobi wszystko, by zaistnieć...
> > > Thriller NIENARODZONY w kinach od 20 marca!
> > > Zobacz zwiastun filmu
> > -->http://klik.wp.pl/?adr=http%3A%2F%2Fcorto.www.wp.pl%2Fas%2Fnienarodzo...
>
> ----------------------------------------------------
> Zło zrobi wszystko, by zaistnieć...
> Thriller NIENARODZONY w kinach od 20 marca!
> Zobacz zwiastun filmu 
> -->http://klik.wp.pl/?adr=http%3A%2F%2Fcorto.www.wp.pl%2Fas%2Fnienarodzo...

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