Page 3 of 5 FirstFirst 12345 LastLast
Results 21 to 30 of 50

Thread: Turtle Graphics...??

  1. #21
    Join Date
    Feb 2005
    Posts
    418
    Rep Power
    0

    Default Re: Turtle Graphics...??

    Quote Originally Posted by crosswire
    Psuedo
    init state
    execute lines 1, then 2, ....

    ....
    1 Pen up
    2 Pen down
    3 Turn right
    4 Turn left
    5, 10 Move forward 10 spaces or a number other than ten
    6 Print the 20 by 20 array
    9 End of data (sentinel)
    }

    jeepers!! thanks that was quick anything else?
    ***Note to the public***
    Since ppl are a tad bit confused as to whether i happen to be male/female... i hope this will clear the air i am a FEMALE .. so stop wid da my ute/nigga/dog/man/boy beast ting!!
    ive spoken

  2. #22
    Join Date
    Oct 2004
    Posts
    4,814
    Rep Power
    24

    Default Re: Turtle Graphics...??

    Quote Originally Posted by Liquid Bunny
    PRIZE? ....uh.. who mentioned a prize.... hmm... YEA man u get a prize to... lol ROPE IN!!!
    4 real . what do i get? I hope is not ur courage dog painting on yu wall. . I want something expensive cuz mi nuh cheap .

  3. #23
    Join Date
    Feb 2005
    Posts
    418
    Rep Power
    0

    Default Re: Turtle Graphics...??

    lol... yea right who u kiddin.. u ...lol...not cheap....lol... not in the same sentence
    ***Note to the public***
    Since ppl are a tad bit confused as to whether i happen to be male/female... i hope this will clear the air i am a FEMALE .. so stop wid da my ute/nigga/dog/man/boy beast ting!!
    ive spoken

  4. #24
    Join Date
    Oct 2004
    Posts
    4,814
    Rep Power
    24

    Default Re: Turtle Graphics...??

    Quote Originally Posted by Liquid Bunny
    lol... yea right who u kiddin.. u ...lol...not cheap....lol... not in the same sentence
    uhhm, what gave you that idea?

  5. #25
    Join Date
    Sep 2004
    Posts
    1,905
    Rep Power
    21

    Default Re: Turtle Graphics...??

    Anybody done yet? Look like some people can just use the book still

  6. #26
    Join Date
    Sep 2004
    Posts
    1,905
    Rep Power
    21

    Default Re: Turtle Graphics...??

    You know this thing was giving me half a box, but me did lazy to use the debugger, I felt I could spot the error. Eventually I debugged it to find an unusual typo for me, a break statement by itself . Its unfinished still.

    Code:
    #include <iostream.h>
    #include <fstream.h>
    
    //enum	dir	{up, right, down, left};
    
    
    #define		BoardSize	50
    class TurtleAndBoard
    {
    	//Attribute:
    	int TurtleDirection;
    	int	TurtleXPosition;
    	int	TurtleYPosition;
    	int	*****Down;
    	int	BoardState[BoardSize][BoardSize];
    
    	//Behaviour:
    public:
    	void InitState();
    	void ReadNextCommand(ifstream & CommandFile);
    	bool PerformCommand(int Command, int CommandParameter, ostream & DisplayHandle);
    };
    
    
    
    
    void TurtleAndBoard::InitState()
    {
    	this->TurtleDirection	=	0;
    	this->TurtleXPosition	=	BoardSize/2;
    	this->TurtleYPosition	=	BoardSize/2;
    	this->*****Down			=	0;
    
    	for(int y = BoardSize - 1; y >= 0; y--)
    	{
    		for(int x = 0; x < BoardSize; x++)
    		{
    			this->BoardState[x][y]	=	0;
    		}
    	}
    
    
    }
    
    bool TurtleAndBoard::PerformCommand(int Command, int CommandParameter, ostream & DisplayHandle)
    {
    
    	switch(Command)
    	{
    	//1 Pen up
    	case 1:
    		this->*****Down	=	0;
    		break;
    	//2 Pen down
    	case 2:
    		this->*****Down	=	1;
    		break;
    	//3 Turn right
    	case 3:
    		this->TurtleDirection++;
    		if(this->TurtleDirection > 3)
    		{
    			this->TurtleDirection = 0;
    		}
    		break;
    	//4 Turn left
    	case 4:
    		this->TurtleDirection--;
    		if(this->TurtleDirection < 0)
    		{
    			this->TurtleDirection = 3;
    		}
    		break;
    	//5, 10 Move forward 10 spaces or a number other than ten
    	case 5:
    		int	i;
    		switch(this->TurtleDirection)
    		{
    		//move up by n spaces
    		case 0:
    			for(i = 0; i < CommandParameter; i++)
    			{
    				//move up
    				this->TurtleYPosition++;
    				if(this->TurtleYPosition > (BoardSize - 1))
    				{
    					this->TurtleYPosition = (BoardSize - 1);
    				}
    
    				if(this->*****Down)
    				{
    					this->BoardState[TurtleXPosition][TurtleYPosition]	=	1;
    				}
    			}
    			break;
    		//move right by n spaces
    		case 1:
    			for(i = 0; i < CommandParameter; i++)
    			{
    				//move right
    				this->TurtleXPosition++;
    				if(this->TurtleXPosition > (BoardSize - 1))
    				{
    					this->TurtleXPosition = (BoardSize - 1);
    				}
    
    				if(this->*****Down)
    				{
    					this->BoardState[TurtleXPosition][TurtleYPosition]	=	1;
    				}
    			}
    			break;
    		//move down by n spaces
    		case 2:
    			for(i = 0; i < CommandParameter; i++)
    			{
    				//move down
    				this->TurtleYPosition--;
    				if(this->TurtleYPosition < 0)
    				{
    					this->TurtleYPosition = 0;
    				}
    
    				if(this->*****Down)
    				{
    					this->BoardState[TurtleXPosition][TurtleYPosition]	=	1;
    				}
    			}
    			break;
    		//move left by n spaces
    		case 3:
    			for(i = 0; i < CommandParameter; i++)
    			{
    				//move left
    				this->TurtleXPosition--;
    				if(this->TurtleXPosition < 0)
    				{
    					this->TurtleXPosition = 0;
    				}
    
    				if(this->*****Down)
    				{
    					this->BoardState[TurtleXPosition][TurtleYPosition]	=	1;
    				}
    			}
    			break;
    		}//end moving n spaces in specified direction
    		break;
    	//6 Print the 20 by 20 array
    	case 6:
    
    		//Start print the highest y row first
    		{
    			for(int y = BoardSize - 1; y >= 0; y--)
    			{
    				for(int x = 0; x < BoardSize; x++)
    				{
    					
    					if(this->BoardState[x][y])
    					{
    						DisplayHandle << "*";
    					}
    					else
    					{
    						DisplayHandle << " ";
    					}
    				}
    				DisplayHandle << "\n";
    			}
    		}
    		break;
    	//9 End of data (sentinel)
    	case 9:
    		//WantAend
    		DisplayHandle << "Yow\n";
    
    		break;
    	}
    
    	return	true;
    }
    
    
    
    int main()
    {
    	TurtleAndBoard	tb;
    
    	//init state
    	tb.InitState();
    
    
    	//execute lines 1, then 2, ....
    
    /*
    2
    5, 12
    3
    5, 12
    3
    5, 12
    3
    5, 12
    1
    6
    9
    */
    
    	tb.PerformCommand(2, 0, cout);
    	tb.PerformCommand(5, 12, cout);
    	tb.PerformCommand(3, 0, cout);
    	tb.PerformCommand(5, 12, cout);
    	tb.PerformCommand(3, 0, cout);
    	tb.PerformCommand(5, 12, cout);
    	tb.PerformCommand(3, 0, cout);
    	tb.PerformCommand(5, 12, cout);
    	tb.PerformCommand(1, 0, cout);
    	tb.PerformCommand(6, 0, cout);
    	tb.PerformCommand(9, 0, cout);
    
    	return	0;
    }
    Let's act on what we agree on now, and argue later on what we don't.
    Black men leave Barbeque alone if Barbeque don't trouble you

  7. #27
    Join Date
    Feb 2005
    Posts
    418
    Rep Power
    0

    Default Re: Turtle Graphics...??

    Wow thank u much appreciated
    ***Note to the public***
    Since ppl are a tad bit confused as to whether i happen to be male/female... i hope this will clear the air i am a FEMALE .. so stop wid da my ute/nigga/dog/man/boy beast ting!!
    ive spoken

  8. #28
    Join Date
    Aug 2004
    Posts
    2,789
    Rep Power
    0

    Default Re: Turtle Graphics...??

    @Liquid ..didnt u want it in full C? that code is c++
    The views expressed in the above post are not neccesarily the views of icuucme.

  9. #29
    Join Date
    Feb 2005
    Posts
    418
    Rep Power
    0

    Default Re: Turtle Graphics...??

    lol funny enough thats what i just realized... i said thanks first n copy n pasted it n mid way looking thru it i was like wtf? oh dear, but its ok i am thankful for the help i kinda understand a lil better now wha i have to do
    ***Note to the public***
    Since ppl are a tad bit confused as to whether i happen to be male/female... i hope this will clear the air i am a FEMALE .. so stop wid da my ute/nigga/dog/man/boy beast ting!!
    ive spoken

  10. #30
    Join Date
    Feb 2005
    Posts
    418
    Rep Power
    0

    Default Re: Turtle Graphics...??

    i dunno wah i doing .....
    ***Note to the public***
    Since ppl are a tad bit confused as to whether i happen to be male/female... i hope this will clear the air i am a FEMALE .. so stop wid da my ute/nigga/dog/man/boy beast ting!!
    ive spoken

Posting Permissions

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