Mercurial > hg > Members > tatsuki > Alice
comparison src/alice/test/topology/aquarium/AutoIncrement.java @ 277:ba4eea27d70d
Refactor to change attribute of threshold value to const class field.
author | kazz <kazz@cr.ie.u-ryukyu.ac.jp> |
---|---|
date | Fri, 18 Oct 2013 01:55:21 +0900 |
parents | ccce30f84380 |
children | 04c769f00be1 |
comparison
equal
deleted
inserted
replaced
276:3e0d1ac4f4a8 | 277:ba4eea27d70d |
---|---|
6 | 6 |
7 public class AutoIncrement extends CodeSegment { | 7 public class AutoIncrement extends CodeSegment { |
8 | 8 |
9 private Receiver position = ids.create(CommandType.PEEK); | 9 private Receiver position = ids.create(CommandType.PEEK); |
10 private Receiver number = ids.create(CommandType.PEEK); | 10 private Receiver number = ids.create(CommandType.PEEK); |
11 private float min = -1.3f; | 11 private static final float MIN = -1.3f; |
12 | 12 |
13 public AutoIncrement(String key,int index){ | 13 public AutoIncrement(String key,int index){ |
14 this.number.setKey("maxsize"); | 14 this.number.setKey("maxsize"); |
15 this.position.setKey(key, index); | 15 this.position.setKey(key, index); |
16 } | 16 } |
18 @Override | 18 @Override |
19 public void run() { | 19 public void run() { |
20 float max = this.number.asInteger()*2-1+0.3f; | 20 float max = this.number.asInteger()*2-1+0.3f; |
21 FishPoint fp = this.position.asClass(FishPoint.class); | 21 FishPoint fp = this.position.asClass(FishPoint.class); |
22 if (fp.getX()+0.01>max){ | 22 if (fp.getX()+0.01>max){ |
23 fp.setXYZ(min, fp.getY(), fp.getZ()); | 23 fp.setXYZ(MIN, fp.getY(), fp.getZ()); |
24 } else if (fp.getX()+0.01< min){ | 24 } else if (fp.getX() + 0.01 < MIN){ |
25 fp.setXYZ(max, fp.getY(), fp.getZ()); | 25 fp.setXYZ(max, fp.getY(), fp.getZ()); |
26 } | 26 } |
27 else { | 27 else { |
28 fp.setXYZ(fp.getX()+0.01f, fp.getY(), fp.getZ()); | 28 fp.setXYZ(fp.getX()+0.01f, fp.getY(), fp.getZ()); |
29 } | 29 } |