Zoo tutorials: [ SQL | Linux | XML ]
ProgZoo: [ Java | C# | VB | C++ | Perl ]
Log in

A Gentle Introduction to
Programming

Tutorial: Quilts - Using methods

 

We can use methods to reduce the amount of code required.

CommandMeaning
Quilt.b
Quilt.c
Quilt.b.turn()
Quilt.b.sew(Quilt.c)

1. Stacking


Big

Change the stack method so that it puts the first quilt on top of the second.



2. Outside square


Big

Create the pattern shown

The outside square can be constructed using the stack method.



3. Four copies


Big

Fix the method quad so that it returns four copies of the input.





4. 16 Copies


Big

If we do much more of this the server will start hurting