Hello Everyone.
The objective of the exercise is to understand that an interface is also a
type.
i.e
String a;
String is the type and a is the reference variable.
interface InterfaceType{
//some code
}
class PersonAddress {
//declare InterfaceType a
private InterfaceType a;
public person (int streetNum, String streetName){
//here pass the constructor arguments into you interface type
a = new InterfaceType(streetNum,streetName);
}
void print(){
system.out.println(a.getStreetNum()) ; // print the getter methods of the
Persons adress
}
}
On Sun, Mar 21, 2010 at 2:56 PM, Cecil H <[email protected]> wrote:
> The homework ask use to do the following.
>
> Write an interface called MyOwnInterface, which has the following
> method
> AddressInterface getAddress();
> The AddressInterface is a Java interface that has the following
> methods.
> int getStreetNumber();
> void setStreetNumber(int streetNumber);
> String getStreetName();
> void setStreetName(String streetName);
> String getCountry();
> void setCountry(String country);
> Write AddressImpl class that implements AddressInterface
> Make the Person class to implement MyOwnInterface.
> Initialize a Person object with proper data and display it.
>
> How would returning the AddressInterface object work? Why wouldn't you
> change
> AddressInterface getAddress() to String getAddress()?
>
> I can post all the classes I have but if someone has a quick
> suggestion. I'd really appreciate the help.
>
> Thanks
> Trey
>
> --
> To post to this group, send email to
> [email protected]
> To unsubscribe from this group, send email to
> [email protected]<javaprogrammingwithpassion%[email protected]>
> For more options, visit this group at
> http://groups.google.com/group/javaprogrammingwithpassion?hl=en
>
> To unsubscribe from this group, send email to javaprogrammingwithpassion+
> unsubscribegooglegroups.com or reply to this email with the words "REMOVE
> ME" as the subject.
>
--
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
To unsubscribe from this group, send email to
javaprogrammingwithpassion+unsubscribegooglegroups.com or reply to this email
with the words "REMOVE ME" as the subject.