Skip to content

Commit

Permalink
clean
Browse files Browse the repository at this point in the history
  • Loading branch information
anonymax25 committed Jan 9, 2022
1 parent 457fc8e commit c57483e
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 21 deletions.
2 changes: 1 addition & 1 deletion projet/funprog-al/src/main/resources/application.conf
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
application {
name = "FunProg"
name = "Mower Simulator"
turn-delay = 100
input-file = "tmp/input.txt"
output-json-file = "tmp/output.json"
Expand Down
2 changes: 1 addition & 1 deletion projet/funprog-al/src/main/scala/progfun/InputLoader.scala
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class InputLoader(filePath: String) {
}

def parseInput(): (Int, Int, List[Mower]) = {
val f: File = File(this.filePath)
val f: File = File(filePath)
val lines: List[String] = f.lines.toList
val sizeLine: String = getFirstLine(lines)
val mowerLines: List[String] = getMowersLines(lines)
Expand Down
4 changes: 2 additions & 2 deletions projet/funprog-al/src/main/scala/progfun/Main.scala
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ object Main extends App {

val conf: Config = ConfigFactory.load()

val loader = new InputLoader(conf.getString("application.input-file"))
val inputLoader = new InputLoader(conf.getString("application.input-file"))

val inputs = loader.parseInput()
val inputs = inputLoader.parseInput()

val x: Int = inputs._1
val y: Int = inputs._2
Expand Down
34 changes: 17 additions & 17 deletions projet/funprog-al/src/main/scala/progfun/mower/Mower.scala
Original file line number Diff line number Diff line change
Expand Up @@ -47,40 +47,40 @@ class Mower(
)

def advance(limit: Point, mowers: List[Mower]): Mower = {
val newPoint: Point = this.direction match {
val newPoint: Point = direction match {
case North() =>
if (isOkMove(this.point.x, this.point.y + 1, point, mowers))
if (isOkMove(point.x, point.y + 1, point, mowers))
new Point(
this.point.x,
this.point.y + 1
point.x,
point.y + 1
)
else
this.point
point
case South() =>
if (isOkMove(this.point.x, this.point.y - 1, point, mowers))
if (isOkMove(point.x, point.y - 1, point, mowers))
new Point(
this.point.x,
this.point.y - 1
point.x,
point.y - 1
)
else
this.point
point

case East() =>
if (isOkMove(this.point.x + 1, this.point.y, point, mowers))
if (isOkMove(point.x + 1, point.y, point, mowers))
new Point(
this.point.x + 1,
this.point.y
point.x + 1,
point.y
)
else
this.point
point
case West() =>
if (isOkMove(this.point.x - 1, this.point.y, point, mowers))
if (isOkMove(point.x - 1, point.y, point, mowers))
new Point(
this.point.x - 1,
this.point.y
point.x - 1,
point.y
)
else
this.point
point
}

new Mower(
Expand Down

0 comments on commit c57483e

Please sign in to comment.