Pathways to CyberInfrastructure

   

TFS


Shodor > CyberPathways > Workshops 2007 > TFS



Wednesday, Feb 21

We continued with the tic-tac-toe project today. For those students that had not got their 3x3 grid and rollovers to work completely in Tuesday's class, Jonathan did a short review session. Next, we tackled the problem of marking squares.

To make it easy to program the process of marking a square, Jonathan introduced the concept of functions. He asked what had to happen each time a square was clicked, and the students told him that the screen had to show the proper mark, and the current player had to be alternated. The students then wrote these two steps into a "function" that was separate from (but called by) all the individual images on the board.

Jonathan also asked, if this function was indeed separate so it "could not see the board," what was the one thing it needed to know each time a play was made. The students told him the function needed to know which spot was clicked on, so we wrote that into the code. By the end of the class, our code had the rollovers and the ability to mark spots with alternating x's and o's.


Not Logged In. Login
©1994-2024 Shodor