Assignment 9, due Oct 28
Part of
the homework for 22C:60 (CS:2630), Fall 2011
|
On every assignment, write your name legibly as it appears on your University ID card! Homework is due on paper at the start of class on the day indicated (usually Friday). Exceptions will be made only by advance arrangement (excepting "acts of God"). Late work must be turned in to the TA's mailbox (ask the CS receptionist in 14 MLH for help). Never push homework under someone's door!
unsigned int mod3(unsigned int x) { while (x > 3) { x = sum of base 4 digits of x } if (x == 3) x = 0; return x; }
A problem: Translate the above to Hawk code. You will have to work out how to do the loop body, perhaps with an inner loop, although there are tricks that may be even faster. (1 point)
There's quite a bit missing from the above specification: How do you create new windows? How does an application determine the size of a window? Ignore this, but do assume that there may be multiple output devices, perhaps a character-only device such as the default Hawk display and also a graphic output device more akin to what you expect on a modern computer. This means that the class window is inherently polymorphic.
a) Give an appropriate interface specification file window.h to be used by SMAL Hawk programs. (0.5 points)
b) Give code for w.putat(x,y) assuming that w, x and y are all local variables of the calling subroutine. (1.0 points)
b) (0.5 points).