Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
m4102_tp1
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Aymane Ismail
m4102_tp1
Commits
f07b6ffc
Commit
f07b6ffc
authored
3 years ago
by
Aymane Ismail
Browse files
Options
Downloads
Patches
Plain Diff
deuxieme commit
parent
e250c1b0
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
Readme.md
+1
-1
1 addition, 1 deletion
Readme.md
src/fr/ulille/iut/m4102/AccesService.java
+51
-13
51 additions, 13 deletions
src/fr/ulille/iut/m4102/AccesService.java
src/fr/ulille/iut/m4102/Intermediaire.java
+54
-26
54 additions, 26 deletions
src/fr/ulille/iut/m4102/Intermediaire.java
with
106 additions
and
40 deletions
Readme.md
+
1
−
1
View file @
f07b6ffc
...
@@ -11,7 +11,7 @@ retournés par le côté serveur.
...
@@ -11,7 +11,7 @@ retournés par le côté serveur.
<valeur> ::= <char> | <chaine> | [0-9]* | [0-9]* "." [0-9]*
<valeur> ::= <char> | <chaine> | [0-9]* | [0-9]* "." [0-9]*
<chaine> ::= "<char>*"
<chaine> ::= "<char>*"
<char> ::= un charactère alphanumérique
<char> ::= un charactère alphanumérique
<reponse> ::=
<reponse> ::=
"resultat:" <type> "," <valeur>
```
```
## Exemples de ce qui devra être transmis
## Exemples de ce qui devra être transmis
...
...
This diff is collapsed.
Click to expand it.
src/fr/ulille/iut/m4102/AccesService.java
+
51
−
13
View file @
f07b6ffc
package
fr.ulille.iut.m4102
;
package
fr.ulille.iut.m4102
;
import
java.util.Arrays
;
/**
/**
* Cette classe se trouvera côté service
* Cette classe se trouvera côté service
* Elle recevra une requête sous forme de chaîne
* Elle recevra une requête sous forme de chaîne
...
@@ -17,10 +19,46 @@ public class AccesService {
...
@@ -17,10 +19,46 @@ public class AccesService {
}
}
public
String
traiteInvocation
(
String
invocation
)
{
public
String
traiteInvocation
(
String
invocation
)
{
// ici, il faudra décomposer la chaîne pour retrouver la méthode appelée
// et les paramètres, réaliser l'invocation sur la classe AlaChaine puis
// renvoyer le résultat sous forme de chaîne.
return
null
;
String
[]
invocDivisee
=
invocation
.
replace
(
"param["
,
""
).
replace
(
"]"
,
""
).
split
(
":"
);
String
nomMethode
=
invocDivisee
[
1
];
String
[]
paramTab
=
Arrays
.
copyOfRange
(
invocDivisee
,
2
,
invocDivisee
.
length
);
String
resultatFormate
=
"resultat:"
;
switch
(
nomMethode
)
{
case
"nombreMots"
:
if
(
paramTab
[
0
].
split
(
","
)[
0
].
equals
(
"string"
))
{
resultatFormate
+=
"int,"
+
alc
.
nombreMots
(
paramTab
[
0
].
split
(
","
)[
1
]);
}
break
;
case
"compteChar"
:
if
(
paramTab
[
0
].
split
(
","
)[
0
].
equals
(
"string"
)
&&
paramTab
[
1
].
split
(
","
)[
0
].
equals
(
"char"
))
{
resultatFormate
+=
"int,"
+
alc
.
compteChar
(
paramTab
[
0
].
split
(
","
)[
1
],
paramTab
[
1
].
split
(
","
)[
1
].
charAt
(
0
));
}
break
;
case
"asphyxie"
:
if
(
paramTab
[
0
].
split
(
","
)[
0
].
equals
(
"string"
))
{
resultatFormate
+=
"string,"
;
try
{
resultatFormate
+=
alc
.
asphyxie
(
paramTab
[
0
].
split
(
","
)[
1
]);
}
catch
(
PasDAirException
e
)
{
resultatFormate
+=
"error"
;
}
}
}
break
;
case
"leetSpeak"
:
if
(
paramTab
[
0
].
split
(
","
)[
0
].
equals
(
"string"
))
{
resultatFormate
+=
"string,"
+
alc
.
leetSpeak
(
paramTab
[
0
].
split
(
","
)[
1
]);
}
break
;
}
return
resultatFormate
;
}
}
}
This diff is collapsed.
Click to expand it.
src/fr/ulille/iut/m4102/Intermediaire.java
+
54
−
26
View file @
f07b6ffc
...
@@ -11,30 +11,58 @@ package fr.ulille.iut.m4102;
...
@@ -11,30 +11,58 @@ package fr.ulille.iut.m4102;
*/
*/
public
class
Intermediaire
implements
AlaChaineInterface
{
public
class
Intermediaire
implements
AlaChaineInterface
{
private
AlaChaine
alc
;
private
AlaChaine
alc
;
private
AccesService
aService
;
public
Intermediaire
()
{
public
Intermediaire
()
{
// pour l'instant on accède directement au service après instanciation
aService
=
new
AccesService
();
alc
=
new
AlaChaine
();
alc
=
new
AlaChaine
();
}
}
public
int
nombreMots
(
String
chaine
)
{
public
int
nombreMots
(
String
chaine
)
{
System
.
out
.
println
(
"Méthode: NombreMots ; Paramètre(String): "
+
chaine
+
" ; Resultat(int): "
+
alc
.
nombreMots
(
chaine
));
/* System.out.println("Méthode: NombreMots ; Paramètre(String): "+chaine +" ; Resultat(int): "+alc.nombreMots(chaine));
return
alc
.
nombreMots
(
chaine
);
return alc.nombreMots(chaine); */
String
invocation
=
"Call:nombreMots:param[string,"
+
chaine
+
"]"
;
String
resInv
=
aService
.
traiteInvocation
(
invocation
);
String
valeur
=
resInv
.
split
(
":"
)[
1
].
split
(
","
)[
1
];
return
Integer
.
parseInt
(
valeur
);
}
}
public
String
asphyxie
(
String
chaine
)
throws
PasDAirException
{
public
String
asphyxie
(
String
chaine
)
throws
PasDAirException
{
System
.
out
.
println
(
"Méthode: asphyxie ; Paramètre(String): "
+
chaine
+
" ; Resultat(String): "
+
alc
.
asphyxie
(
chaine
)+
" ; PasDAirException: Déjà asphyxiée"
);
/* System.out.println("Méthode: asphyxie ; Paramètre(String): "+chaine +" ; Resultat(String): "+alc.asphyxie(chaine)+" ; PasDAirException: Déjà asphyxiée");
return
alc
.
asphyxie
(
chaine
);
return alc.asphyxie(chaine);*/
String
invocation
=
"Call:asphyxie:param[string,"
+
chaine
+
"]"
;
String
resInv
=
aService
.
traiteInvocation
(
invocation
);
String
valeur
=
resInv
.
split
(
":"
)[
1
].
split
(
","
)[
1
];
return
valeur
;
}
}
public
String
leetSpeak
(
String
chaine
)
{
public
String
leetSpeak
(
String
chaine
)
{
System
.
out
.
println
(
"Méthode: leetSpeak ; Paramètre(String): "
+
chaine
+
" ; Resultat(String): "
+
alc
.
leetSpeak
(
chaine
));
/* System.out.println("Méthode: leetSpeak ; Paramètre(String): "+chaine +" ; Resultat(String): "+alc.leetSpeak(chaine));
return
alc
.
leetSpeak
(
chaine
);
return alc.leetSpeak(chaine);*/
String
invocation
=
"Call:leetSpeak:param[string,"
+
chaine
+
"]"
;
String
res
=
aService
.
traiteInvocation
(
invocation
);
String
valeur
=
res
.
split
(
":"
)[
1
].
split
(
","
)[
1
];
return
valeur
;
}
}
public
int
compteChar
(
String
chaine
,
char
c
)
{
public
int
compteChar
(
String
chaine
,
char
c
)
{
System
.
out
.
println
(
"Méthode: compteChar ; Paramètre(String, char): "
+
chaine
+
", "
+
c
+
" ; Resultat(int): "
+
alc
.
compteChar
(
chaine
,
c
));
/* System.out.println("Méthode: compteChar ; Paramètre(String, char): "+chaine+", "+c+" ; Resultat(int): "+alc.compteChar(chaine, c));
return
alc
.
compteChar
(
chaine
,
c
);
return alc.compteChar(chaine, c);*/
String
invocation
=
"Call:compteChar:param[string, "
+
chaine
+
"]:param[char,"
+
c
+
"]"
;
String
res
=
aService
.
traiteInvocation
(
invocation
);
String
valeur
=
res
.
split
(
":"
)[
1
].
split
(
","
)[
1
];
return
Integer
.
parseInt
(
valeur
);
}
}
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment