Results 1 to 7 of 7

Thread: Classes, and where to put code

Threaded View

  1. #1

    Thread Starter
    type Woss is new Grumpy; wossname's Avatar
    Join Date
    Aug 2002
    Location
    #!/bin/bash
    Posts
    5,682

    Question Classes, and where to put code

    Lets say I have a chess game in development, I have all the game logic worked out but not the graphics.

    ===

    Would it be better OOP practice to put the code for drawing each chess piece within the various chesspiece classes and pass a Graphics object to the class for drawing on...

    Code:
    //pseudocode
    for each piece on chessboard
    piece.DrawSelf(chessboard.Graphics)
    next piece
    Or...

    Have a single central drawing routine and pass each chess piece to it in turn?

    Code:
    //pseudocode
    for each piece on chessboard
    DrawPiece(piece)
    next piece
    ===

    If it is the latter, how would you get all the classes info into the drawing function, since much of the classes would be private or protected.

    This would be an applicable question if instead of graphics, it was file input/output or several other things.

    how would you go about it?
    Last edited by wossname; Mar 19th, 2004 at 03:13 PM.
    I don't live here any more.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width