The logo language made the concept of turtlegraphics famous. Imagine a mechanica
ID: 3615901 • Letter: T
Question
The logo language made the concept of turtlegraphics famous. Imagine a mechanical turtle that walks arounda room under your control. So the turtle will move according toyour commands. The turtle holds a pen in one of two positions, upor down. While the pen is down, the turtle traces out its path asit moves, and while the pen is up, the turtle moves freely withoutwriting anything.
The set of commands are the following :
Design a GUI with:
Represent the turtle as a small filled circle (drawing a turtleis optional). The turtle starts at the centre of the window and itsdefault direction is up. Then it will move according to thecommands. The turtle should not execute a command that makes itexit from the window.
this is what I've done sofar
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
public class Turtle extends JFrame{
JPanel floor ;
JButton pen_up ;
JButton pen_down ;
JButton turn_right;
JButton turn_left;
JButton move;
JButton clear;
JTextField pix ;
public Turtle(){
super("HW");
setLayout(newFlowLayout());
setSize(150,400);
floor = new JPanel();
add(floor);
pen_up = new JButton("PenUP");
add(pen_up);
pen_down = new JButton("PenDOWN");
add(pen_down);
turn_right = newJButton("Turn Right");
add(turn_right);
turn_left = new JButton("TurnLeft");
add(turn_left);
move = newJButton("Move");
add(move);
clear = newJButton("Clear");
add(clear);
pix = new JTextField(10);
add(pix);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
class Listener1 implements ActionListener{
public voidactionPerformed(ActionEvent ae){
}
}
public static void main(String[] args){
Turtle test = newTurtle();
test.setVisible(true);
}
}
Explanation / Answer
x.
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.