(1) Let us look back at the Pyramid example. Implement a Pyramid class recursively, using an approach similar to that used for the Bullseye class. Allow the user to specify the number of levels and the overall width (which can be the same as the height).
Note: The main difference in techniques involves the positioning of the components. For the bullseye, the outer circle and inner bullseye were concentric. For the pyramid you will need to relocate the bottom rectangle and the upper pyramid to achieve the desired effect.
(2) Write a recursive function named countdown(n) that can simulate a rocket launch countdown. The function should accept the starting count (for example, 5) and count down to 1, followed by the word “LIFTOFF !!” Here is what the output should look like:
5 4 3 2 1 LIFTOFF ! !
Note: Feel free to use time delay for nice effects.
Already registered? Login
Not Account? Sign up
Enter your email address to reset your password
Back to Login? Click here