Ajouter un commentaire

Niroken

lol je vais faire mon chieur mais....

import java.util.*;
import java.lang.*;
import java.awt.*;
import javax.swing.*;
import java.io.*;
 
public class testing 
{
	public static void main(String[] args)
	{
		MaForme1 maForme1 = new MaForme1();
				
		ArrayList <MaForme> arrayList = new ArrayList <MaForme>();
		
		arrayList.add(maForme1);
	}
}

abstract class MaForme implements Serializable{ 

  protected boolean selected = false; 
  
    public abstract void dessine(Graphics g) ; 
    
    public abstract void tourne (double a); 
    
    public abstract boolean appartient (int x, int y); 
    
    public abstract int nb(); 
     
} 

class MaForme1 extends MaForme implements Serializable{ 

 private static final long serialVersionUID = 1L; 

   public int x; 

   public int y; 

    public MaForme1(){ 
    } 
  
    public MaForme1(int a, int o){ 
       this.x=a; 
       this.y=o; 
    } 
    
    public int distance(MaForme1 p) { 
        int dx = p.x - x ; 
        int dy = p.y - y ; 
        int res= dx*dx + dy*dy; 
        return res ;          
    } 

   public void tourne(double a) 
   { 
    MaForme1 o = new MaForme1(0,0); 
     int ox = this.x - o.x ; 
     int oy = this.y - o.y ; 
     double cosa = Math.cos (a) ; 
     double sina = Math.sin (a) ; 
     x = (int) (o.x + cosa * ox - sina * oy) ; 
     y = (int) (o.y + sina * ox + cosa * oy) ;              
   } 

   public void dessine(Graphics g) { 
      // TODO Auto-generated method stub 
      Graphics2D g2 = (Graphics2D)g; 
       
       if (selected) 
            g2.setColor(Color.green); 
         else 
            g2.setColor(Color.blue);       
        
        g2.drawRect(x,y,1,1); 
   } 

   public boolean appartient(int x, int y) { 
      MaForme1 p = new MaForme1(x,y); 
      if(this.equals(p)){ 
         return false; 
      } 
      return true; 
   } 

   public int nb() { 
       
      return 1; 
} 
}

Pour moi RAS la, ca compile et éxécution nickel :)

Il faut plus de code lol!

Filtered HTML

Plain text

CAPTCHA
Cette question permet de vérifier que vous n'êtes pas un robot spammeur :-)
  QQQ    W     W  EEEE  X   X  X   X 
Q Q W W E X X X X
Q Q W W W EEE X X
Q QQ W W W E X X X X
QQQQ W W EEEE X X X X
Q