Difference between revisions of "Assessment 2008 Hard"

From Progzoo
Jump to: navigation, search
(Ludo)
(Cards)
Line 172: Line 172:
 
}
 
}
 
</prog>
 
</prog>
<answer>
+
<answer><![CDATA[
 +
static void doubleTB(Graphics2D g,int x,int y,BufferedImage img){
 +
  g.translate(x,y);
 +
  g.drawImage(img,-8,-8,null);
 +
  g.translate(-x-x,-y-y);
 +
  g.rotate(Math.PI);
 +
  g.drawImage(img,-8,-8,null);
 +
  g.rotate(-Math.PI);
 +
  g.translate(x,y);
 +
}
 +
 
 +
static void fillOff(Graphics2D g,int x,int y,BufferedImage img){
 +
  g.translate(x,y);
 +
  g.drawImage(img,-8,-8,null);
 +
  g.translate(-x,-y);
 +
}
 +
 
 +
static void pips(Graphics2D g,int x,int y,int n,BufferedImage img){
 +
  int w=4; int h=6;
 +
  int tl = 20;int rl=13;
 +
  g.translate(x,y);
 +
  if (n==1||n==3||n==5||n==9)
 +
    g.drawImage(img,-8,-8,null);
 +
  if (n==2||n==3)
 +
    doubleTB(g,0,tl,img);
 +
  if (n>3){
 +
    doubleTB(g,rl,tl,img);
 +
    doubleTB(g,-rl,tl,img);
 +
  }
 +
  if (n==6||n==7||n==8){
 +
    fillOff(g,rl,0,img);
 +
    fillOff(g,-rl,0,img);
 +
  }
 +
  if (n==7)
 +
    fillOff(g,0,-tl/2,img);
 +
  if (n==8)
 +
    doubleTB(g,0,tl/2,img);
 +
  if (n==9||n==10){
 +
    doubleTB(g,-rl,tl/3,img);
 +
    doubleTB(g,rl,tl/3,img);
 +
  }
 +
  if (n==10) doubleTB(g,0,2*tl/3,img);
 +
  g.translate(-x,-y);
 +
}
 +
 
 
static void drawFlag(Graphics2D g){
 
static void drawFlag(Graphics2D g){
   BufferedImage img= new BufferedImage(448,270,
+
  int p = 4;
       BufferedImage.TYPE_INT_ARGB);  
+
  int r = 8;
   try{  
+
  int w = 40;
    img = (BufferedImage)ImageIO.read(new File("cards.png"));
+
  int h = 60;
    g.drawImage(img,0,0,null);
+
  g.setRenderingHint(
   }catch(Exception e){ }
+
  RenderingHints.KEY_ANTIALIASING,
 +
  RenderingHints.VALUE_ANTIALIAS_ON);
 +
   BufferedImage img = new BufferedImage(16,16,
 +
       BufferedImage.TYPE_INT_ARGB);
 +
   String [] suits = "diamonds.png clubs.png hearts.png spades.png".split(" ");
 +
  for (int j=0;j<4;j++){
 +
    try {
 +
      img = (BufferedImage)ImageIO.read(new File(suits[j]));
 +
    }catch (Exception e){}
 +
    for (int i=0;i<10;i++)
 +
    {
 +
      g.setColor(Color.white);
 +
      g.fillRoundRect((p+w)*i+p,(p+h)*j+p,w,h,r,r);
 +
      g.setColor(Color.black);
 +
      g.drawRoundRect((p+w)*i+p,(p+h)*j+p,w,h,r,r);
 +
      g.setColor((j%2==0)?Color.red:Color.black);
 +
      pips(g,(p+w)*i+p+w/2,(p+h)*j+p+h/2,i+1,img);
 +
    }
 +
   }
 
}
 
}
</answer>
+
]]></answer>
 
</question>
 
</question>
  

Revision as of 01:11, 10 November 2008

Fanorona

Fanorona
  • The separation is 20
  • The disks have radius 6
  • The background is 184x104
  • The blue is 64,64,255


[Font] [Default] [Show] [Resize] [History] [Profile]

Snakes and Ladders

Snakes and Ladders
  • The squares are 24
  • The background is 241x241


[Font] [Default] [Show] [Resize] [History] [Profile]

Ludo

Ludo
  • The background is 256x256
  • The gray is 228, 228, 228


[Font] [Default] [Show] [Resize] [History] [Profile]

Cards

Deck of Cards


[Font] [Default] [Show] [Resize] [History] [Profile]

Monopoly

This is a large image and takes too much memory on the the progzoo system. Please use Dr Java or similar.

  • The width of each property is 85
  • The background is 1040x1040
  • You should use strings in the array


Monopoly.png

[Font] [Default] [Show] [Resize] [History] [Profile]