Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.ArrayList;
- import java.util.Collections;
- import java.util.Comparator;
- public class Point {
- public ArrayList<Point> neighbors;
- public static Integer []types ={0,1,2,3};
- public int type;
- public int staticField;
- public boolean isPedestrian;
- public Point() {
- type=0;
- staticField = 100000;
- neighbors= new ArrayList<Point>();
- }
- public void clear() {
- staticField = 100000;
- }
- public boolean calcStaticField() {
- Boolean toReturn = false;
- for (Point neighbor: neighbors) {
- if (neighbor.staticField < this.staticField -1){
- this.staticField = neighbor.staticField +1;
- toReturn = true;
- }
- }
- return toReturn;
- }
- public void move(){
- if (isPedestrian){
- Point neighbor = Collections.min(neighbors, Comparator.comparing(n -> {
- if (!n.isPedestrian && n.staticField < this.staticField ){
- return n.staticField;
- }
- else {
- return 100;
- }
- }));
- if (!(neighbor == null)){
- neighbor.isPedestrian=true;
- this.isPedestrian=false;
- }
- }
- }
- public void addNeighbor(Point nei) {
- neighbors.add(nei);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement