Help Please

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Jova

    Help Please

    Ok I have a class called WordPlayer and in this class I have 2 methods

    setTray // sets the player Tray with to its parameter.

    getTray // it gets the player Tray of Tiles

    and the tray implements a stack

    how do I get a tile on the player tray
    I attached the WordPlayer class is this enough info.



    class WordPlayer extends Player
    {private Tray playerTray;

    public Tray getTray()
    {

    return playerTray;
    }//ends getTray

    public void setTray()
    {
    playerTray = new Tray();
    }//ends setTray




    }//ends WordPlayer




  • Brad BARCLAY

    #2
    Re: Help Please

    Jova wrote:
    [color=blue]
    > how do I get a tile on the player tray
    > I attached the WordPlayer class is this enough info.[/color]

    How should I know? You don't provide an implementation for the Tray
    object itself.

    I'm guessing that what you need to know is that you can chain method
    calls. I'm making some assumptions about the methods in the Tray class
    here, but the code below is perfectly valid Java:

    WordPlayer wp = new WordPlayer();
    Tray tray = new Tray();
    wp.setTray(tray );

    // Here's the important part...
    wp.getTray().ad dTile(someTileO bj);

    Note that calling a method that has a return type is the same in Java
    as having an actual variable of that type available locally. The
    compiler will see that "wp.getTray ()" has a return value of type Tray,
    thus you can use "wp.getTray ()" anywhere where you'd use an object of
    type Tray. This means that you can use it as the stem upon which you
    call Tray object methods, as above (assuming the Tray object has an
    object method called "addTile", of course.

    Note that, depending on how you're designing your code, it might just
    be better to add methods to WordPlayer for things like "addTile" and
    "removeTile ", which will in turn add or remove the tile from the tray
    itself.

    HTH!

    Brad BARCLAY

    --
    =-=-=-=-=-=-=-=-=
    From the OS/2 WARP v4.5 Desktop of Brad BARCLAY.
    The jSyncManager Project: http://www.jsyncmanager.org
    

    Comment

    • Jova

      #3
      Re: Help Please

      THANK YOU SO MUCH!!!!!!!. That help out lot,
      "Brad BARCLAY" <bbarclay@jsync manager.org> wrote in message
      news:kwFgb.2514 99$Lnr1.55009@n ews01.bloor.is. net.cable.roger s.com...[color=blue]
      > Jova wrote:
      >[color=green]
      > > how do I get a tile on the player tray
      > > I attached the WordPlayer class is this enough info.[/color]
      >
      > How should I know? You don't provide an implementation for the Tray
      > object itself.
      >
      > I'm guessing that what you need to know is that you can chain method
      > calls. I'm making some assumptions about the methods in the Tray class
      > here, but the code below is perfectly valid Java:
      >
      > WordPlayer wp = new WordPlayer();
      > Tray tray = new Tray();
      > wp.setTray(tray );
      >
      > // Here's the important part...
      > wp.getTray().ad dTile(someTileO bj);
      >
      > Note that calling a method that has a return type is the same in Java
      > as having an actual variable of that type available locally. The
      > compiler will see that "wp.getTray ()" has a return value of type Tray,
      > thus you can use "wp.getTray ()" anywhere where you'd use an object of
      > type Tray. This means that you can use it as the stem upon which you
      > call Tray object methods, as above (assuming the Tray object has an
      > object method called "addTile", of course.
      >
      > Note that, depending on how you're designing your code, it might just
      > be better to add methods to WordPlayer for things like "addTile" and
      > "removeTile ", which will in turn add or remove the tile from the tray
      > itself.
      >
      > HTH!
      >
      > Brad BARCLAY
      >
      > --
      > =-=-=-=-=-=-=-=-=
      > From the OS/2 WARP v4.5 Desktop of Brad BARCLAY.
      > The jSyncManager Project: http://www.jsyncmanager.org
      > 
      >[/color]


      Comment

      Working...