Thread: Turtle Trouble

  1. #1
    Registered User
    Join Date
    Apr 2013
    Posts
    45

    Turtle Trouble

    The Logo language, made the concept of turtle graphics famous. It was a mechanical turtle that walked around and drew shapes. The turtle holds a pen in one of two positions, up or down. While the
    pen is down the turtle traces out shapes as it moves; while the pen is up, the turtle moves about freely without writing anything. This is similar to the way some line draw programs work.
    You are to design such a program:

    Use a 20 by 20 array or floor which is initialized to zeros. Keep track of the current position of the turtle at all times, the direction it is heading, and whether the pen is currently up or down. Assume that
    the turtle always starts position 0,0 on the floor with its pen up, heading to the right or east.

    The set of turtle commands your program must process are:
    1 change pen position
    2 turn
    3 move forward
    4 print
    5 change brush
    6 erase/start over
    7 jump
    8 see menu again
    9 end program

    There must be at least
    a turtle class ( turtle.h , turtle.cpp )
    a pen class ( pen.h, pen.cpp )
    a direction class ( direction.h , direction.cpp ),
    a position class ( position.h, position.cpp )
    and a driver ( driver.cpp )
    The driver must not contain any function prototypes/implementations: place them in separate files



    Well... I have some questions:

    Would it be smarter to put the floor in the position class or right smack dab in the driver?

    Also, how do I get the turtle to interact with the floor, or the turtle to hold the pen? I guess I am having trouble understanding implementing different classes to different classes.

    I have already written some of the things I would need in each class, but how do these classes interact with each other?

    Please help!

  2. #2
    - - - - - - - - oogabooga's Avatar
    Join Date
    Jan 2008
    Posts
    2,808
    It would make no sense to put the floor in the position class.
    You could make it it's own class.

    You have some things to explicate:

    1 change pen position
    Presumably toggles the pen from up to down or vice versa.

    2 turn
    Presumably takes a parameter to turn clockwise or counterclockwise by 90 degrees.

    3 move forward
    May take a param to say how many steps to move in the current direction, or may just take one step.

    4 print
    Prints the current state of the floor.

    5 change brush
    I have no idea what a "brush" is???

    6 erase/start over
    Reset floor and turtle.

    7 jump
    I have no idea what "jump" means???

    8 see menu again

    9 end program
    The cost of software maintenance increases with the square of the programmer's creativity. - Robert D. Bliss

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Turtle algorithm
    By PJYelton in forum A Brief History of Cprogramming.com
    Replies: 11
    Last Post: 08-05-2003, 10:28 AM
  2. Turtle CVS and sourceforge, no 'ls'
    By nickname_changed in forum A Brief History of Cprogramming.com
    Replies: 0
    Last Post: 08-05-2003, 03:19 AM
  3. turtle graphics with c
    By datainjector in forum C Programming
    Replies: 4
    Last Post: 08-11-2002, 07:11 PM
  4. turtle graphics
    By condorx in forum C Programming
    Replies: 2
    Last Post: 05-10-2002, 02:27 PM
  5. Turtle Game - Please Help
    By ketchup57v in forum C++ Programming
    Replies: 6
    Last Post: 01-19-2002, 01:43 PM