-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSiatka.java
More file actions
46 lines (38 loc) · 1.13 KB
/
Siatka.java
File metadata and controls
46 lines (38 loc) · 1.13 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
import greenfoot.*;
import java.util.*;
/**
* Write a description of class FishCatcher here.
*
* @author (your name)
* @version (a version number or a date)
*/
public class Siatka extends Actor
{
private static Siatka siatka = null;
private List<Rybka> listaRybek = null;
public static Siatka getFishCatcher() {
if(siatka == null) {
siatka = new Siatka();
siatka.getImage().rotate(-90);
siatka.listaRybek = new ArrayList<Rybka>();
}
return siatka;
}
public List<Rybka> wezListeRybek() {
return listaRybek;
}
/**
* Act - do whatever the FishCatcher wants to do. This method is called whenever
* the 'Act' or 'Run' button gets pressed in the environment.
*/
public void act()
{
move(10);
wezListeRybek().addAll(getObjectsInRange(200, Rybka.class));
if(wezListeRybek().size() > 0) {
getWorld().removeObjects(wezListeRybek());
wezListeRybek().clear();
getWorld().removeObject(this);
}
}
}