Interfaces and aggregation

From: Markos Charatzas (xarm_at_forthnet.gr)
Date: 01/30/04

  • Next message: BarryNL: "Re: Interfaces and aggregation"
    Date: Fri, 30 Jan 2004 15:57:56 +0200
    
    

    Hello to all,

    Suppose we have a class Ship and a class Cabin.

    Both of these classes support a common interface, say Query and Cabin is
    part of Ship. Therefore,

    class Ship implements Query
    {
            String name;
            Cabin cabin;

            public String getQuery()
            {
            }
    }

    class Cabin implements Query
    {

            public String getQuery()
            {
            }
    }

    Now, inside cabin.getQuery() I need to know the ship.name value.
    What's the best approach to achieve this? Should I pass a reference of
    Ship in Cabin once a cabin object is created? Any other possible way?

    Thanks in advance,
    Markos Charatzas


  • Next message: BarryNL: "Re: Interfaces and aggregation"