You must follow the directory structure and naming conventions outlined in the notes on Git. In particular, all your work for this assignment must be in a directory named assign02 within your pairNN repository (where NN is your pair number).
For this exercise, you will design and develop (a pared down version of) the classic game of Space Invaders. In this game, there are a number of space aliens that are descending from the top of the screen. They move left to right and then down at uniform speed. The player controls a laser canon that can be moved left or right along the bottom of the screen. The player can fire the laser, which shoots straight up. If the laser hits an alien, the alien dies. If any alien makes it to the bottom of the screen (or hits the cannon), the player loses. If the player destroys all the invaders, the player wins.
To get a sense of the game, you can play this online version of the game. Your version doesn’t need to have all of the features of the online game; in particular, you don’t need levels, different kinds of aliens, protective bunkers, shooting aliens, or the mysterious red alien that flies across the top of the screen. You don’t need to keep score and the player only needs to have one life. Of course, you can implement all of these nice features, but remember, you’re graded for your program design, not making a cool video game. So whatever you add, make sure it’s well designed.
Design classes to represent ternary trees of numbers. (A ternary tree is like a binary tree, except nodes have three subtrees instead of two.)
In this representation, values are stored at both nodes and leaves, and there are no empty trees. Note that this means that trees with two or three values cannot be represented.
Implement the methods size (how many numbers are there in the tree), sum (sums all the numbers in the tree), prod (computes the product of all the numbers in the tree), contains? (is a given number in the tree?), map (apply a function to every number in the tree), and max (what’s the largest number in the tree?).