CS 105 Midterm Examination
Thursday, Oct. 29, 1998
NAME:
There are 7 questions on this examination. The point values associated with the questions are shown in the table above. You have 75 minutes to complete the examination. You should not consult any references while completing this examination. Show all answers in the spaces provided in the examination booklet. Paper for scrap work will be made available.
Question Points Score 1 10 2 15 3 15 4 16 5 18 6 16 7 10 TOTAL 100
One feature of PhotoShop you can use to produce "nifty" horizontal rules is the "gradient tool". It can be used to fill a region of an image with a range of varying colors. For example, with the gradient tool you can make a horizontal rule that ranges through all the colors of the spectrum.
Imagine that you made such a rule to use to underline the header of a page with a very thin band of color. Suppose you made the rule just 1 pixel high and 250 pixels wide. Assume you used the gradient tool to construct the rule so that the pixels ranged over the spectrum in such a way that no two pixels had the same color.
import java.awt.*;
import javaTools.*;
public class ColorMixer extends AppletTemplate
{
Slider redness, greenness, blueness;
public void begin() {
redness = new Slider( 255, 0, 255,180);
greenness = new Slider( 255, 0, 255,180);
blueness = new Slider( 255, 0, 255,180);
add(redness);
add(greenness);
add(blueness);
drawBackground(255,255,255);
}
private void drawBackground(int r,int g,int b) {
pen.fillRect( new Color(r, g, b));
pen.fillRect( 0,134, 66,66, ``Red'');
pen.fillRect( 66,134, 68,66, ``Green'');
pen.fillRect( 133,134 ,66,66, ``Blue'');
pen.drawString( r, 25,175);
pen.drawString( g, 81,175);
pen.drawString( b,147,175);
}
public void scroll() {
drawBackground(redness.getValue(),greenness.getValue(),blueness.getValue());
}
}
pen.fillRect( new Color(r, g, b));
pen.fillRect( 66,134, 68,66, ``Green'');
pen.fillRect( 0,134, 66,66, ``Red'');
pen.fillRect( 133,134 ,66,66, ``Blue'');
Briefly describe how (if at all) this would change the behavior of the applet.
pen.fillRect( new Color(r, g, b));
pen.drawString( r, 25,175);
pen.drawString( g, 81,175);
pen.drawString( b,147,175);
pen.fillRect( 0,134, 66,66, ``Red'');
pen.fillRect( 66,134, 68,66, ``Green'');
pen.fillRect( 133,134 ,66,66, ``Blue'');
Briefly describe how (if at all) this would change the behavior of the applet.
Show how to modify the applet so that the top scrollbar controls the "blueness", the middle scrollbar still controls the "greenness", and the bottom scrollbar controls the "redness"
Show your changes on the listing given on the first page of the problem.
There are many ways to do this. You may show any way that is not unreasonably complicated.
For each example, please briefly explain the problems with the HTML shown and indicate how to modify the HTML to make it correct while producing what the author appeared to have in mind. You can either clearly mark up the code shown or write a complete revision in the space provided.
<H3><FONT SIZE=+3><CENTER> 1997-98 </CENTER> <BR> <CENTER> SOME INTERESTING HEADER </FONT></CENTER> </H3>
<HR size=5> <TABLE align=left> <TD><IMG SRC="guesswhat.jpeg" WIDTH="288" HEIGHT="214"></TD> </TABLE> <P> i don't remember much...
<TABLE>
<TR>
<TD COLSPAN=2 ALIGN=CENTER>
<FONT SIZE=5><B>Vital Stats</FONT></B></TD>
</TR>
<TR>
<TD><LI><A HREF=''http://espnet.sportzone.com''>
<P ALIGN=center>ESPN</P></A></TD>
<TD><LI><A HREF=''http://www.msnbc.com''>
<P ALIGN=left>MSNBC</P></A></TD>
</TD>
</TABLE>
Descriptions:
Suppose defective ethernet hardware was installed on all the computers on an ethernet so that none of them did the "CD" part correctly. In particular, assume that a) a computer that detects a collision would still be smart enough to try to send the message again later (a random amount of time after it next detects that the network is idle), but b) a computer that detects a collision is not smart enough to stop sending its own message (instead, it keeps sending until the message is complete although certainly not successfully delivered).
Would such behavior:
BRIEFLY, justify your answer.