Sunday, March 25, 2012

Teaching APCS: Chapter 8 Arrays and ArrayLists!

After studying Chapter 8 about static arrays and the ArrayList class in Cay Horstmann's great text "Big Java," I thought it was time for a little Case Study of my own. Unfortunately, with the advent of Case Studies on the AP Exam, I find I have little time for my own labs. However, we went ahead and wrote a program called Chess960 to create random chess boards according to Bobby Fischer's rules. Wow, this project surely took on a life of its own! We wrote V1 which generated one such board. Then we wrote V2 which refactored or simplified V1's code. Then V3 generated all 960 combinations printing them on screen and storing them to a file 960.txt. We just finished V4 which reads one line from the 960 lines in 960.txt to set up a board with Half-ASCII graphics. V4 is actually playable as we added a move() method too! With the AP Exam looming, we have to stop this project now and finish the real Case Study: GridWorld. So, the move() method is very simple. You can play "Jr. Chess" without castling, en passant or piece promotion. So, there's much more we could do with this project such as checking for valid moves, recording unfinished games, resuming unfinished games and checking for checkmates or stalemates. However, I met my goal of reinforcing concepts related to creating and using 1D and 2D static arrays and 1D ArrayLists. I hope you find this helpful whether you are an APCS student or teacher. Enjoy!



Well, that's all folks!

No comments:

Post a Comment