Bonjour,
j'ai un petit problème d'héritage en java : voila je vous explique;
j'ai crée un class ball.java
import java.awt.*;
import java.util.Random;
public class Ball
{
public float pos;
private BallPath ballPath;
private Color color;
public Random R;
public Ball(BallPath ballPath, float pos, Color color)
{
this.ballPath = ballPath;
this.pos = pos;
this.color = color;
}
public void paint(Graphics g)
{
Point p = ballPath.getPathPoint(pos);
g.setColor(color);
g.fillOval(p.x-DEF.BALL_RADIUS/2, p.y-DEF.BALL_RADIUS/2, DEF.BALL_RADIUS+1,DEF.BALL_RADIUS+1);
g.setColor(Color.yellow);
g.drawOval(p.x-DEF.BALL_RADIUS/2, p.y-DEF.BALL_RADIUS/2, DEF.BALL_RADIUS,DEF.BALL_RADIUS);
}
}
ensuite j'ai crée un class qui hérite de set class Ballspécial
import java.awt.Color;
import java.awt.Graphics;
import java.awt.Point;
public class Ballspecial extends Ball{
public float pos;
private BallPath ballPath;
private Color color;
public Ballspecial(BallPath ballPath,float pos,Color color)
{
super(ballPath, pos, color);
this.ballPath = ballPath;
this.pos = pos;
this.color = color;
}
public void paint(Graphics g)
{
Point p = ballPath.getPathPoint(pos);
g.setColor(color);
g.fillOval(p.x-DEF.BALL_RADIUS/2, p.y-DEF.BALL_RADIUS/2, DEF.BALL_RADIUS+1,DEF.BALL_RADIUS+1);
g.setColor(Color.red);
g.drawOval(p.x-DEF.BALL_RADIUS/2, p.y-DEF.BALL_RADIUS/2, DEF.BALL_RADIUS,DEF.BALL_RADIUS);
}
}
j'ai réussi d'afficher les ball dans une chaine de ball défini sous forme de string mai pas la ball spécial
j'ai fai des instructions de ce genre
balls = new ArrayList<Ball>();
ballspecial=new ArrayList<Ballspecial>();
Merci en avance de votre aide
Configuration: Windows Vista
Firefox 3.0.8