Script Java
Script Java Script Java
11.4 Stack public class Left extends Command { private int argument; public Left(int n) {argument = n;} public void run() {turtle.right(-argument);} public String toString() {return "left "+argument+"\n";} } public class Sequence extends Command { private Stack commands; public Sequence() {commands = new Stack();} public void add(Command c) {commands.push(c);} public void undo() {if (!commands.empty()) commands.pop();} public void run() { int size = commands.size(); for (int i=0;i
11.4 Stack public NumCheckbox(int n, boolean state, CheckboxGroup group) { super(String.valueOf(n),state,group); num = n; } } public int getNum() {return num;} public class Drawing extends Frame { public Drawing() { setTitle("Drawing"); setBounds(400,0,400,500); setVisible(true); } } public void paint(Graphics g) {logo.run(g);} private void place(Component comp,int x,int y,int width,int height) { comp.setBounds(x, y, width, height); add(comp); } public UserFrame() { setTitle("Editor"); setLayout(null); setBounds(0,0,400,515); setResizable(false); commands = new CheckboxGroup(); arguments = new CheckboxGroup(); place(text = new TextArea(),30,80,340,340); text.setBackground(Color.white); place(button = new Button("CLEAR"),30,450,60,20); button.setBackground(Color.white); button.addActionListener(this); place(new Checkbox("FD",true,commands),120,440,40,15); place(new Checkbox("BK",false,commands),120,455,40,15); place(new Checkbox("RT",false,commands),120,470,40,15); place(new Checkbox("LT",false,commands),120,485,40,15); place(new NumCheckbox(5,true,arguments),170,440,40,15); place(new NumCheckbox(30,false,arguments),170,455,40,15); place(new NumCheckbox(50,false,arguments),170,470,40,15); place(new NumCheckbox(90,false,arguments),170,485,40,15); place(button = new Button("DO"),240,450,60,20); button.setBackground(Color.white); button.addActionListener(this); place(button = new Button("UNDO"),310,450,60,20); button.setBackground(Color.white); button.addActionListener(this); logo = new Logo(); drawing = new Drawing(); setVisible(true); } public void actionPerformed(ActionEvent event) { if (event.getActionCommand().equals("CLEAR")) { logo.clear(); 241
- Seite 189 und 190: 7.4 Exception Handling Handling Ins
- Seite 191 und 192: 7.4 Exception Handling Wenn es im P
- Seite 193 und 194: 7.4 Exception Handling public void
- Seite 195 und 196: 7.4 Exception Handling Schlüsselwo
- Seite 197 und 198: 7.5 Zusammenfassung ExceptionHandli
- Seite 199 und 200: 8.1 Abstrakte Methoden und Klassen
- Seite 201 und 202: 8.1 Abstrakte Methoden und Klassen
- Seite 203 und 204: 8.1 Abstrakte Methoden und Klassen
- Seite 205 und 206: 8.1 Abstrakte Methoden und Klassen
- Seite 207 und 208: 8.1 Abstrakte Methoden und Klassen
- Seite 209 und 210: 8.1 Abstrakte Methoden und Klassen
- Seite 211 und 212: 8.1 Abstrakte Methoden und Klassen
- Seite 213 und 214: 9.1 Interfaces und Adapter-Klassen
- Seite 215 und 216: 9.1 Interfaces und Adapter-Klassen
- Seite 217 und 218: 9.1 Interfaces und Adapter-Klassen
- Seite 219 und 220: 9.1 Interfaces und Adapter-Klassen
- Seite 221 und 222: 9.2 Zusammenfassung Muss man zwecks
- Seite 223 und 224: 10.1 Zweidimensionaler Array 10Arra
- Seite 225 und 226: 10.1 Zweidimensionaler Array public
- Seite 227 und 228: 10.1 Zweidimensionaler Array new Ti
- Seite 229 und 230: 11.1 Turtle-Geometrie } (int)Math.r
- Seite 231 und 232: 11.2 Vererbung forward() right() Ab
- Seite 233 und 234: 11.3 Rekursion Abbildung 11-3: Turt
- Seite 235 und 236: 11.3 Rekursion } setSize(400,400);
- Seite 237 und 238: 11.3 Rekursion public void tree(int
- Seite 239: 11.4 Stack import java.awt.event.*;
- Seite 243 und 244: 11.4 Stack Abbildung 11-8: Turtle -
- Seite 245 und 246: 11.4 Stack forward 30 push() forwar
- Seite 247 und 248: 12.1 Binärer Baum } else return "f
- Seite 249 und 250: 12.1 Binärer Baum Abbildung 12-2:
- Seite 251 und 252: 13.1 Anhang A: Java Syntax A nhäng
- Seite 253 und 254: 13.1 Anhang A: Java Syntax Prior. O
- Seite 255 und 256: 13.2 Anhang B: Übersicht Klassenbi
- Seite 257 und 258: 13.2 Anhang B: Übersicht Klassenbi
- Seite 259 und 260: 13.4 Anhang D: Prinzipien guten Pro
- Seite 261 und 262: 13.4 Anhang D: Prinzipien guten Pro
- Seite 263 und 264: 13.4 Anhang D: Prinzipien guten Pro
- Seite 265 und 266: 13.4 Anhang D: Prinzipien guten Pro
- Seite 267 und 268: 14.1 Stichwortverzeichnis S chwortv
- Seite 269 und 270: 14.1 Stichwortverzeichnis Logo, Pro
11.4 Stack<br />
public NumCheckbox(int n, boolean state, CheckboxGroup group) {<br />
super(String.valueOf(n),state,group);<br />
num = n;<br />
}<br />
}<br />
public int getNum() {return num;}<br />
public class Drawing extends Frame {<br />
public Drawing() {<br />
setTitle("Drawing");<br />
setBounds(400,0,400,500);<br />
setVisible(true);<br />
}<br />
}<br />
public void paint(Graphics g) {logo.run(g);}<br />
private void place(Component comp,int x,int y,int width,int height) {<br />
comp.setBounds(x, y, width, height);<br />
add(comp);<br />
}<br />
public UserFrame() {<br />
setTitle("Editor");<br />
setLayout(null);<br />
setBounds(0,0,400,515);<br />
setResizable(false);<br />
commands = new CheckboxGroup();<br />
arguments = new CheckboxGroup();<br />
place(text = new TextArea(),30,80,340,340);<br />
text.setBackground(Color.white);<br />
place(button = new Button("CLEAR"),30,450,60,20);<br />
button.setBackground(Color.white);<br />
button.addActionListener(this);<br />
place(new Checkbox("FD",true,commands),120,440,40,15);<br />
place(new Checkbox("BK",false,commands),120,455,40,15);<br />
place(new Checkbox("RT",false,commands),120,470,40,15);<br />
place(new Checkbox("LT",false,commands),120,485,40,15);<br />
place(new NumCheckbox(5,true,arguments),170,440,40,15);<br />
place(new NumCheckbox(30,false,arguments),170,455,40,15);<br />
place(new NumCheckbox(50,false,arguments),170,470,40,15);<br />
place(new NumCheckbox(90,false,arguments),170,485,40,15);<br />
place(button = new Button("DO"),240,450,60,20);<br />
button.setBackground(Color.white);<br />
button.addActionListener(this);<br />
place(button = new Button("UNDO"),310,450,60,20);<br />
button.setBackground(Color.white);<br />
button.addActionListener(this);<br />
logo = new Logo();<br />
drawing = new Drawing();<br />
setVisible(true);<br />
}<br />
public void actionPerformed(ActionEvent event) {<br />
if (event.getActionCommand().equals("CLEAR")) {<br />
logo.clear();<br />
241