Peace,
I would like some help. As far as I've understood thus far:
a "is a" b = inheritance of 'a' from super('b')
a "has a" b = 'b' is a property of class 'a'
now how can I understand the relationship of an interface to a class,
as in:
'a' implements 'b'
Thanks in advance,
God Bless,
shree
LaieTechie wrote:
> On Sat, 04 Nov 2006 02:46:04 +0000, newsnet customer wrote:
>
> > Hi,
> >
> > I want to implement as association relationship in Java. I understand the
> > implementation for this kind of relationship is called "containment".
> > However, I can not find the code for this on the internet. From what is
> > explained on the internet, I believe the code would look something like
> > this:
> >
> > /*A Car 'has a' Wheel relationship*/
> >
> > public class wheel{
> > public wheel(){
> > }
> > }
> > }
> > public class Car{
> > Wheel w;
> >
> > public Car(){
> > w = new Wheel();
> > }
> > }
> > }
> > Is this the basic idea?
> > by the way, what does containment mean?
> >
> > ST
>
> There are two types of relationships you should concern yourself with in
> Java:
>
> Has A: this indicates containment. In you example, a Car has a Wheel.
> Your container class should have a member property ("instance variable")
> of that type.
>
> Is A: this denotes inheritance. A Car is a vehicle. You indicate
> inheritance with "extends" (for classes) or "implements" (for interfaces).
>
> Public class Car extends Vehicle {}
>
> You may also run into "uses" relationships, which may translate into
> instance variables or local variables (variables defined within a certain
> scope, like a method).
>
> HTH,
> La`ie Techie
|