-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
89f31db
commit 1cc6ee1
Showing
4 changed files
with
19 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 12 additions & 9 deletions
21
projet/funprog-al/src/main/scala/progfun/mower/Action.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,18 @@ | ||
package fr.esgi.al.action | ||
package fr.esgi.al.funprog | ||
|
||
abstract class Action { | ||
def getChar(action: Action): String = action match { | ||
case Left() => "G" | ||
case Right() => "D" | ||
case Advance() => "A" | ||
class Action(str: String) {} | ||
|
||
object Action { | ||
|
||
def apply(str: String): Action = str match { | ||
case "G" => new Left("G") | ||
case "D" => new Right("D") | ||
case "A" => new Advance("A") | ||
} | ||
} | ||
|
||
case class Left() extends Action {} | ||
case class Left(str: String) extends Action(str: String) {} | ||
|
||
case class Right() extends Action {} | ||
case class Right(str: String) extends Action(str: String) {} | ||
|
||
case class Advance() extends Action {} | ||
case class Advance(str: String) extends Action(str: String) {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
package fr.esgi.al.funprog | ||
|
||
case class Mower(x: Int, y: Int, direction: Direction) {} | ||
import fr.esgi.al.funprog._ | ||
|
||
case class Mower(x: Int, y: Int, direction: Direction, actions: List[Action]) {} |