Skip to content

Commit

Permalink
write outputs to file
Browse files Browse the repository at this point in the history
  • Loading branch information
anonymax25 committed Jan 9, 2022
1 parent c57483e commit a4ba98f
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 3 deletions.
19 changes: 16 additions & 3 deletions projet/funprog-al/src/main/scala/progfun/Main.scala
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,21 @@ package fr.esgi.al.funprog
import com.typesafe.config.{Config, ConfigFactory}
import play.api.libs.json._
import fr.esgi.al.funprog._
import java.io._

final case class DonneesIncorectesException(
val message: String
) extends Exception(message)

object Main extends App {

def writeFile(filename: String, s: String): Unit = {
val file = new File(filename)
val bw = new BufferedWriter(new FileWriter(file))
bw.write(s)
bw.close()
}

val conf: Config = ConfigFactory.load()

val inputLoader = new InputLoader(conf.getString("application.input-file"))
Expand All @@ -30,7 +38,12 @@ object Main extends App {

val executed = Environnement.execute(env)

// println(Json.prettyPrint(executed.toJson))

println(CSVExporter.export(executed.mowers))
writeFile(
conf.getString("application.output-json-file"),
Json.prettyPrint(executed.toJson)
)
writeFile(
conf.getString("application.output-csv-file"),
CSVExporter.export(executed.mowers)
)
}
2 changes: 2 additions & 0 deletions projet/funprog-al/tmp/output.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
numéro,début_x,début_y,début_direction,fin_x,fin_y,fin_direction,instructions
1,3,3,E,5,1,E,AADAADADDA
24 changes: 24 additions & 0 deletions projet/funprog-al/tmp/output.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"limit" : {
"x" : 5,
"y" : 5
},
"tondeuse" : [ {
"id" : 1,
"debut" : {
"point" : {
"x" : 3,
"y" : 3
},
"direction" : "E"
},
"instructions" : [ "A", "A", "D", "A", "A", "D", "A", "D", "D", "A" ],
"fin" : {
"point" : {
"x" : 5,
"y" : 1
},
"direction" : "E"
}
} ]
}

0 comments on commit a4ba98f

Please sign in to comment.