From dd8febe84e80f37113dd364315ec5688e220c012 Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=B4me=20Benoit?= Date: Fri, 13 Apr 2018 10:18:56 +0200 Subject: [PATCH] exo6: add the basic code structure with the right class hierarchy MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Jérôme Benoit --- exo6/Chiffre.java | 7 +++ exo6/Expression.java | 5 +++ exo6/Facteur.java | 4 ++ exo6/Main.java | 10 +++++ exo6/Makefile | 101 +++++++++++++++++++++++++++++++++++++++++++ exo6/Opadd.java | 4 ++ exo6/Opdiv.java | 7 +++ exo6/Opminus.java | 7 +++ exo6/Opmul.java | 4 ++ exo6/Opmulti.java | 7 +++ exo6/Opplus.java | 7 +++ exo6/Parenthese.java | 7 +++ exo6/Terme.java | 4 ++ exo6/Variable.java | 7 +++ 14 files changed, 181 insertions(+) create mode 100644 exo6/Chiffre.java create mode 100644 exo6/Expression.java create mode 100644 exo6/Facteur.java create mode 100644 exo6/Main.java create mode 100644 exo6/Makefile create mode 100644 exo6/Opadd.java create mode 100644 exo6/Opdiv.java create mode 100644 exo6/Opminus.java create mode 100644 exo6/Opmul.java create mode 100644 exo6/Opmulti.java create mode 100644 exo6/Opplus.java create mode 100644 exo6/Parenthese.java create mode 100644 exo6/Terme.java create mode 100644 exo6/Variable.java diff --git a/exo6/Chiffre.java b/exo6/Chiffre.java new file mode 100644 index 0000000..1a0c3cb --- /dev/null +++ b/exo6/Chiffre.java @@ -0,0 +1,7 @@ + +class Chiffre extends Facteur { + + public boolean evaluer() { + return true; + } +} diff --git a/exo6/Expression.java b/exo6/Expression.java new file mode 100644 index 0000000..d89d26a --- /dev/null +++ b/exo6/Expression.java @@ -0,0 +1,5 @@ + +public abstract class Expression { + + abstract boolean evaluer(); +} diff --git a/exo6/Facteur.java b/exo6/Facteur.java new file mode 100644 index 0000000..8481daf --- /dev/null +++ b/exo6/Facteur.java @@ -0,0 +1,4 @@ + +abstract class Facteur extends Terme { + +} diff --git a/exo6/Main.java b/exo6/Main.java new file mode 100644 index 0000000..5bc0ec4 --- /dev/null +++ b/exo6/Main.java @@ -0,0 +1,10 @@ + +class Main { + + /** + * The main() function + * @param String[] args main() function arguments array + */ + public static void main(String[] args) { + } +} diff --git a/exo6/Makefile b/exo6/Makefile new file mode 100644 index 0000000..06d4e73 --- /dev/null +++ b/exo6/Makefile @@ -0,0 +1,101 @@ +# define compiler and compiler flag variables +# define a variable for compiler flags (JFLAGS) +# define a variable for the compiler (JC) +# define a variable for the Java Virtual Machine (JVM) + +JFLAGS = -g +JC = javac +JVM = java + +# +# Clear any default targets for building .class files from .java files; we +# will provide our own target entry to do this in this makefile. +# make has a set of default targets for different suffixes (like .c.o) +# Currently, clearing the default for .java.class is not necessary since +# make does not have a definition for this target, but later versions of +# make may, so it doesn't hurt to make sure that we clear any default +# definitions for these +# + +.SUFFIXES: .java .class + + +# +# Here is our target entry for creating .class files from .java files +# This is a target entry that uses the suffix rule syntax: +# DSTS: +# rule +# DSTS (Dependency Suffix Target Suffix) +# 'TS' is the suffix of the target file, 'DS' is the suffix of the dependency +# file, and 'rule' is the rule for building a target +# '$*' is a built-in macro that gets the basename of the current target +# Remember that there must be a < tab > before the command line ('rule') +# + +.java.class: + $(JC) $(JFLAGS) $*.java + + +# +# CLASSES is a macro consisting of N words (one for each java source file) +# When a single line is too long, use \ to split lines that then will be +# considered as a single line. For example: +# NAME = Camilo \ + Juan +# is understood as +# NAME = Camilo Juan + +CLASSES = \ + Expression.java \ + Terme.java \ + Opadd.java \ + Opplus.java \ + Opminus.java \ + Facteur.java \ + Opmul.java \ + Opmulti.java \ + Opdiv.java \ + Chiffre.java \ + Variable.java \ + Parenthese.java \ + Main.java + +# +# MAIN is a variable with the name of the file containing the main method +# + +MAIN = Main + +# +# the default make target entry +# for this example it is the target classes + +default: classes + + +# Next line is a target dependency line +# This target entry uses Suffix Replacement within a macro: +# $(macroname:string1=string2) +# In the words in the macro named 'macroname' replace 'string1' with 'string2' +# Below we are replacing the suffix .java of all words in the macro CLASSES +# with the .class suffix +# + +classes: $(CLASSES:.java=.class) + + +# Next two lines contain a target for running the program +# Remember the tab in the second line. +# $(JMV) y $(MAIN) are replaced by their values + +run: $(MAIN).class + $(JVM) $(MAIN) + +# this line is to remove all unneeded files from +# the directory when we are finished executing(saves space) +# and "cleans up" the directory of unneeded .class files +# RM is a predefined macro in make (RM = rm -f) +# + +clean: + $(RM) *.class diff --git a/exo6/Opadd.java b/exo6/Opadd.java new file mode 100644 index 0000000..81b3bda --- /dev/null +++ b/exo6/Opadd.java @@ -0,0 +1,4 @@ + +abstract class Opadd extends Expression { + +} diff --git a/exo6/Opdiv.java b/exo6/Opdiv.java new file mode 100644 index 0000000..6ac4715 --- /dev/null +++ b/exo6/Opdiv.java @@ -0,0 +1,7 @@ + +class Opdiv extends Opmul { + + public boolean evaluer() { + return true; + } +} diff --git a/exo6/Opminus.java b/exo6/Opminus.java new file mode 100644 index 0000000..c200b74 --- /dev/null +++ b/exo6/Opminus.java @@ -0,0 +1,7 @@ + +class Opminus extends Opadd { + + public boolean evaluer() { + return true; + } +} diff --git a/exo6/Opmul.java b/exo6/Opmul.java new file mode 100644 index 0000000..736b4ef --- /dev/null +++ b/exo6/Opmul.java @@ -0,0 +1,4 @@ + +abstract class Opmul extends Terme { + +} diff --git a/exo6/Opmulti.java b/exo6/Opmulti.java new file mode 100644 index 0000000..c2bf12a --- /dev/null +++ b/exo6/Opmulti.java @@ -0,0 +1,7 @@ + +class Opmulti extends Opmul { + + public boolean evaluer() { + return true; + } +} diff --git a/exo6/Opplus.java b/exo6/Opplus.java new file mode 100644 index 0000000..3049f60 --- /dev/null +++ b/exo6/Opplus.java @@ -0,0 +1,7 @@ + +class Opplus extends Opadd { + + public boolean evaluer() { + return true; + } +} diff --git a/exo6/Parenthese.java b/exo6/Parenthese.java new file mode 100644 index 0000000..067fcdd --- /dev/null +++ b/exo6/Parenthese.java @@ -0,0 +1,7 @@ + +class Parenthese extends Facteur { + + public boolean evaluer() { + return true; + } +} diff --git a/exo6/Terme.java b/exo6/Terme.java new file mode 100644 index 0000000..b3bf443 --- /dev/null +++ b/exo6/Terme.java @@ -0,0 +1,4 @@ + +abstract class Terme extends Expression { + +} diff --git a/exo6/Variable.java b/exo6/Variable.java new file mode 100644 index 0000000..d023c98 --- /dev/null +++ b/exo6/Variable.java @@ -0,0 +1,7 @@ + +class Variable extends Terme { + + public boolean evaluer() { + return true; + } +} -- 2.34.1