sondos
31-10-2005, 12:08 PM
سويت تصحيح الكود
هل هو صحيح ول فيه غلك
التغييرات بالاون الاحمر
‘Modify the class CannonBall so that the ball is colored blue when the
ball is moving upward, and colored red when the ball is descending.’
import java.awt.*;
//to be more specific, java.awt.Point does the job
public class CannonBall extends Ball {
public CannonBall (Point loc, int r, double dx, double dy) {
//invoke Ball's constructor
super(loc, r);
setMotion(dx, dy);
}
public double GravityEffect = 0.3;
public void move () {
if( changeInY += GravityEffect)
ball.setColor(red);
break;
if(changeINX +=GravityEffect(
ball.setColor(blue);
super.move(); //update the ball position
}
}
هل هو صحيح ول فيه غلك
التغييرات بالاون الاحمر
‘Modify the class CannonBall so that the ball is colored blue when the
ball is moving upward, and colored red when the ball is descending.’
import java.awt.*;
//to be more specific, java.awt.Point does the job
public class CannonBall extends Ball {
public CannonBall (Point loc, int r, double dx, double dy) {
//invoke Ball's constructor
super(loc, r);
setMotion(dx, dy);
}
public double GravityEffect = 0.3;
public void move () {
if( changeInY += GravityEffect)
ball.setColor(red);
break;
if(changeINX +=GravityEffect(
ball.setColor(blue);
super.move(); //update the ball position
}
}