Difference between revisions of "For Tutorial 2"

From Progzoo
Jump to: navigation, search
(Drawing Squares)
(Increase the gap)
Line 31: Line 31:
 
<question title='Horizontal Squares' imgOut='flag.png' width='105' height='105'
 
<question title='Horizontal Squares' imgOut='flag.png' width='105' height='105'
 
   className="Raster" rows='10' level='1'>  
 
   className="Raster" rows='10' level='1'>  
Increase the gap between the squares. You can do that by changing <code>5*i</code> to <code>10*i</code>
+
Increase the gap between the squares. You can do that by changing <code>10*i</code> to <code>20*i</code>
  
 
[[Image:sqfor22.png|frame|Row of Squares]]<prog lang="java"><![CDATA[
 
[[Image:sqfor22.png|frame|Row of Squares]]<prog lang="java"><![CDATA[
 
static void drawFlag(Graphics g){
 
static void drawFlag(Graphics g){
 
   for (int i=0;i<5;i++){
 
   for (int i=0;i<5;i++){
     g.drawRect(5*i, 45 ,8 ,8);
+
     g.drawRect(10*i, 45 ,8 ,8);
 
   }
 
   }
 
}
 
}
Line 42: Line 42:
 
static void drawFlag(Graphics g){
 
static void drawFlag(Graphics g){
 
   for (int i=0;i<5;i++){
 
   for (int i=0;i<5;i++){
     g.drawRect(10*i, 45, 8, 8);
+
     g.drawRect(20*i, 45, 8, 8);
 
   }
 
   }
 
}
 
}

Revision as of 20:27, 24 September 2008

Increase the gap

Increase the gap between the squares. You can do that by changing 10*i to 20*i

Row of Squares
[Font] [Default] [Show] [Resize] [History] [Profile]

Horizontal Squares

Draw a horizontal row of squares

Horizontal Row of Squares
[Font] [Default] [Show] [Resize] [History] [Profile]