Advertisement
Guest User

2ªParte - Questao 1

a guest
Jan 26th, 2015
257
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.95 KB | None | 0 0
  1. import aguiaj.iscte.*;
  2. import aguiaj.iscte.Color;
  3.  
  4. class AreaRect {
  5.  
  6.     final int x;
  7.     final int y;
  8.     final int width;
  9.     final int height;
  10.    
  11.     //Construtor
  12.     public AreaRect(int x, int y, int width, int height) {
  13.         if(x < 0 || y < 0 || width < 0 || height < 0)
  14.             throw new IllegalArgumentException ("Valores invárlidos");
  15.         this.x=x;
  16.         this.y=y;
  17.         this.width=width;
  18.         this.height=height;
  19.     }
  20.    
  21.     //ponto 2
  22.     public static void selection (ColorImage image, int x, int y, int width, int height){
  23.         Color white =  new Color(255,255,255);
  24.         for(int i = x; i < width+x; i++){
  25.             image.setColor(i, y, white);
  26.             image.setColor(i, y+height, white);
  27.         }
  28.         for(int i = y; i < height+y; i++){
  29.             image.setColor(x, i, white);
  30.             image.setColor(x+width, i, white);
  31.         }
  32.     }
  33.    
  34.     //ponto 3
  35.     public boolean selectionPossible (ColorImage image){
  36.         if(width < image.getWidth() && height < image.getHeight())
  37.             return true;
  38.         else
  39.             return false;
  40.        
  41.     }
  42. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement