Question: Q 5 ) Use for loop and the methods moveTo ( ) , forward ( ) , left ( ) , right ( ) to

Q5) Use for loop and the methods moveTo(), forward(), left(), right() to write code in java to draw the following shapes
Graphics2D g2d;
public void left(double a){
g2d.rotate(-a * Math.PI /180);
}
public void right(double a){
g2d.rotate(a * Math.PI /180);
}
public void forward(int length){
g2d.drawLine(0,0, length, 0);
g2d.translate(length,0);
}
public void moveTo(int x, int y){
g2d.translate(x, y);
}
Q 5 ) Use for loop and the methods moveTo ( ) ,

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!