CS 120 Midterm 2 – The Test of Spam
class spam { int width, height, x,y,count; public spam(int w, int h) { width = w; height = h; count = 12; } public move(int a, int b) { y = b; x = a; } public draw(Graphics match) { match.fillRect(x, y,width, height); } } public class nigeria extends java.applet.Applet { int count = 5; spam s1, s2, s3; public nigeria() { s1 = new spam(70,30); s2 = new spam(35,30); s3 = new spam(10,30); s1.move(30,100); s2.move(65,130); s3.move(1,1); count = 0; } public void paint(Graphics g) { s1.draw(g); s2.draw(g); g.drawString("The Count: "+count, 200,200); } }
|
What is the first
method to run from the program above?
How many classes does
the program above have?
Why do we care tham SPAM is illegal in Virgina?
Name any place where a filled
rectangle appears.
Which is more true
a) Methods
contain classes
b) Classes contain methods
What type of Spam is most common
in my email inbox
a) Spam from Nigeria.
b) Spam selling Korean toys.
c)
Spam from Hormel.
d) Useful spam.
Suppose the applet has a bounding box of 500 by 500. In other words, the window containing the applet is 500 x 500. What happens if you try and draw a rectangle from 200,200 to 700, 700.
a) The program won't compile.
b) The program crashes when you run it.
c) The rectangle never appears.
d) Spam isn't about rectangles. Spam runs in circles.
e) Only those parts of the rectangle that fit within the bounding
box appear.
Where did they get the name SPAM? Hint, it's not the food product.
Write me code. You can get at
most 9 points.
(1 point) Write me a program that draws a set of
circles running in a diagonal from the upper left of the screen to
the lower right of the screen. You must use a loop.
(3 points)
Write me a program that uses a three level heirarchy to draw two
letters, each of which has two stamps on it.
(3 points each)
Finish the program at http://euclid.nmu.edu/~randy/Classes/Midterm2