-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Les 3 visiteurs EvalNum, EvalShow, EvalToExp dans le package net.cofa…
…res.visiteur.eval
- Loading branch information
1 parent
550c661
commit 1ccc7d5
Showing
11 changed files
with
227 additions
and
36 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<project-shared-configuration> | ||
<!-- | ||
This file contains additional configuration written by modules in the NetBeans IDE. | ||
The configuration is intended to be shared among all the users of project and | ||
therefore it is assumed to be part of version control checkout. | ||
Without this configuration present, some functionality in the IDE may be limited or fail altogether. | ||
--> | ||
<properties xmlns="http://www.netbeans.org/ns/maven-properties-data/1"> | ||
<!-- | ||
Properties that influence various parts of the IDE, especially code formatting and the like. | ||
You can copy and paste the single properties, into the pom.xml file and the IDE will pick them up. | ||
That way multiple projects can share the same settings (useful for formatting rules for example). | ||
Any value defined here will override the pom.xml file value but is only applicable to the current project. | ||
--> | ||
<netbeans.hint.license>gpl30</netbeans.hint.license> | ||
</properties> | ||
</project-shared-configuration> |
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
This file was deleted.
Oops, something went wrong.
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
/* | ||
* Copyright (C) 2019 pfares | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
package net.cofares.visiteur.eval; | ||
|
||
import net.cofares.model.Add; | ||
import net.cofares.model.Const; | ||
import net.cofares.model.Sous; | ||
|
||
/** | ||
* | ||
* @author pfares | ||
*/ | ||
public interface Eval<T> { | ||
|
||
T eval(Const c); | ||
|
||
T eval(Add a); | ||
|
||
T eval(Sous a); | ||
|
||
} |
31 changes: 31 additions & 0 deletions
31
ExpMath/src/main/java/net/cofares/visiteur/eval/EvalNum.java
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 |
---|---|---|
@@ -0,0 +1,31 @@ | ||
/* | ||
* To change this license header, choose License Headers in Project Properties. | ||
* To change this template file, choose Tools | Templates | ||
* and open the template in the editor. | ||
*/ | ||
package net.cofares.visiteur.eval; | ||
|
||
import net.cofares.model.Add; | ||
import net.cofares.model.Const; | ||
import net.cofares.model.Sous; | ||
|
||
/** | ||
* Le visiteur EvalNum | ||
* @author Pascal Fares | ||
*/ | ||
public class EvalNum implements Eval<Integer> { | ||
@Override | ||
public Integer eval(Const c){ | ||
return c.getI(); | ||
} | ||
|
||
@Override | ||
public Integer eval(Add a){ | ||
return a.getE1().evalNum()+a.getE2().evalNum(); | ||
} | ||
|
||
@Override | ||
public Integer eval(Sous a){ | ||
return a.getE1().evalNum()-a.getE2().evalNum(); | ||
} | ||
} |
44 changes: 44 additions & 0 deletions
44
ExpMath/src/main/java/net/cofares/visiteur/eval/EvalShow.java
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 |
---|---|---|
@@ -0,0 +1,44 @@ | ||
/* | ||
* Copyright (C) 2019 pfares | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
package net.cofares.visiteur.eval; | ||
|
||
import net.cofares.model.Add; | ||
import net.cofares.model.Const; | ||
import net.cofares.model.Sous; | ||
|
||
/** | ||
* LE visiteur evalShow | ||
* @author pfares | ||
*/ | ||
public class EvalShow implements Eval<String> { | ||
|
||
@Override | ||
public String eval(Const c) { | ||
return "Const:"+c.getI(); | ||
} | ||
|
||
@Override | ||
public String eval(Add a) { | ||
return "("+a.getE1().show()+"+"+a.getE2().show()+ ")"; | ||
} | ||
|
||
@Override | ||
public String eval(Sous a) { | ||
return "("+a.getE1().show()+"-"+a.getE2().show()+ ")"; | ||
} | ||
|
||
} |
45 changes: 45 additions & 0 deletions
45
ExpMath/src/main/java/net/cofares/visiteur/eval/EvalToExp.java
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 |
---|---|---|
@@ -0,0 +1,45 @@ | ||
/* | ||
* Copyright (C) 2019 pfares | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
package net.cofares.visiteur.eval; | ||
|
||
import net.cofares.model.Add; | ||
import net.cofares.model.Const; | ||
import net.cofares.model.Expression; | ||
import net.cofares.model.Sous; | ||
|
||
/** | ||
* LE visiteur eval | ||
* @author pfares | ||
*/ | ||
public class EvalToExp implements Eval<Expression> { | ||
|
||
@Override | ||
public Expression eval(Const c) { | ||
return c; | ||
} | ||
|
||
@Override | ||
public Expression eval(Add a) { | ||
return Const.create(a.getE1().evalNum()+a.getE2().evalNum()); | ||
} | ||
|
||
@Override | ||
public Expression eval(Sous a) { | ||
return Const.create(a.getE1().evalNum()-a.getE2().evalNum()); | ||
} | ||
|
||
} |