Skip to content

Commit 25701d6

Browse files
committed
change code structure
1 parent a962275 commit 25701d6

File tree

5 files changed

+33
-7
lines changed

5 files changed

+33
-7
lines changed

App/src/finder/TriangleFinder.kt

+2-4
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package finder
22

3-
import ice1000.models.Line
43
import ice1000.models.Point
4+
import ice1000.models.Triangle
55
import java.awt.image.BufferedImage
66
import java.io.File
77
import javax.imageio.ImageIO
@@ -20,9 +20,7 @@ open class TriangleFinder(image: BufferedImage) : Finder666(image) {
2020
*/
2121
override fun send(point: Point): Boolean {
2222
val ret = point connect pointCache1 && pointCache1 connect pointCache && point connect pointCache
23-
drawLine(Line(pointCache1, pointCache))
24-
drawLine(Line(point, pointCache))
25-
drawLine(Line(point, pointCache1))
23+
drawTriangle(Triangle(point, pointCache, pointCache1))
2624
pointCache = pointCache1
2725
pointCache1 = point
2826
return ret

src/ice1000/models/Area.kt

+2
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ abstract class Area(val origin: BufferedImage) {
1616
image.setRGB(p.x, p.y, if (this[p.x, p.y]) Color.BLUE.rgb else Color.ORANGE.rgb)
1717
}
1818

19+
fun drawTriangle(triangle: Triangle) = triangle.lines().forEach { line -> drawLine(line) }
20+
1921
/** @return True is white, False is black */
2022
operator fun get(x: Int, y: Int) = Binarization.gray(origin.getRGB(x, y)) > average
2123

src/ice1000/models/Triangles.kt src/ice1000/models/Triangle.kt

+4-3
Original file line numberDiff line numberDiff line change
@@ -4,22 +4,23 @@ package ice1000.models
44
* @author ice1000
55
* Created by ice1000 on 2016/8/10.
66
*/
7-
class Triangles(x: Point, y: Point, z: Point) {
7+
class Triangle(x: Point, y: Point, z: Point) {
88
val a = Line(x, y)
99
val b = Line(y, z)
1010
val c = Line(x, z)
1111

12-
1312
fun contains(point: Point): Boolean {
1413
return true
1514
}
1615

1716
override fun equals(other: Any?): Boolean {
18-
if (other == null || other !is Triangles) return false
17+
if (other == null || other !is Triangle) return false
1918
if (c != other.c || b != other.b || a != other.a) return false
2019
return true
2120
}
2221

22+
fun lines() = listOf(a, b, c)
23+
2324
override fun hashCode(): Int {
2425
var result = a.hashCode()
2526
result = 31 * result + b.hashCode()

test/core/sandbox/JavaCodes.java

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
package core.sandbox;
2+
3+
/**
4+
* @author ice1000
5+
* Created by ice1000 on 2016/8/11.
6+
*/
7+
public class JavaCodes {
8+
public static void main(String[] args) {
9+
System.out.println("Hello World");
10+
}
11+
}

test/core/sandbox/KotlinCodes.kt

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
package core.sandbox
2+
3+
/**
4+
* @author ice1000
5+
* Created by ice1000 on 2016/8/11.
6+
*/
7+
8+
infix fun Boolean.exactly(other: Boolean) = this || other
9+
10+
fun main(args: Array<String>) {
11+
val b = true
12+
val a = false
13+
if (a exactly b) println("a exactly b")
14+
}

0 commit comments

Comments
 (0)