add Quality of dev, noSQL, reseau

master
antoine.perederii 1 year ago
parent f88413d950
commit 6c50ffef32

@ -0,0 +1,675 @@
{
"_id": {
"$oid": "65684dcd7dd7c6e85078cad1"
},
"titre": "La ligne verte",
"titre_original": "The Green Mile",
"annee": 1999,
"realisation": {
"nom": "Darabont",
"prenom": "Franck"
},
"casting": [
{
"nom": "Hanks",
"prenom": "Tom"
},
{
"nom": "Duncan",
"prenom": "Michael Clarke"
},
{
"nom": "Morse",
"prenom": "David"
}
]
}
{
"_id": {
"$oid": "65684dcd7dd7c6e85078cad2"
},
"titre": "Le parrain",
"titre_original": "The Godfather",
"annee": 1972,
"realisation": {
"nom": "Copolla",
"prenom": "Francis Ford"
},
"casting": [
{
"nom": "Brando",
"prenom": "Marlon"
},
{
"nom": "Pacino",
"prenom": "Al"
},
{
"nom": "Caan",
"prenom": "James"
}
]
}
{
"_id": {
"$oid": "65684dcd7dd7c6e85078cad3"
},
"titre": "Le silence des agneaux",
"titre_original": "The Silence of the Lambs",
"annee": 1991,
"realisation": {
"nom": "Demme",
"prenom": "Jonathan"
},
"casting": [
{
"nom": "Foster",
"prenom": "Jodie"
},
{
"nom": "Hopkins",
"prenom": "Anthony"
}
]
}
{
"_id": {
"$oid": "65684dcd7dd7c6e85078cad4"
},
"titre": "Forrest Gump",
"annee": 1994,
"realisation": {
"nom": "Zemeckis",
"prenom": "Robert"
},
"casting": [
{
"nom": "Hanks",
"prenom": "Tom"
},
{
"nom": "Wright",
"prenom": "Robin"
},
{
"nom": "Sinise",
"prenom": "Gary"
}
]
}
{
"_id": {
"$oid": "65684dcd7dd7c6e85078cad5"
},
"titre": "Gladiator",
"titre_original": "Gladiator",
"annee": 2000,
"realisation": {
"nom": "Scott",
"prenom": "Ridley"
}
}
{
"_id": {
"$oid": "65684dcd7dd7c6e85078cad6"
},
"titre": "Matrix",
"titre_original": "The Matrix",
"annee": 1999
}
{
"_id": {
"$oid": "65684dcd7dd7c6e85078cad7"
},
"titre": "Star Wars, épisode I : La Menace fantôme",
"titre_original": "Star Wars: Episode I - The Phantom Menace",
"annee": 1999,
"realisation": {
"nom": "Lucas",
"prenom": "George"
}
}
{
"_id": {
"$oid": "65684dcd7dd7c6e85078cad8"
},
"titre": "Star Wars, épisode II : L'Attaque des clones",
"titre_original": "Star Wars: Episode II - Attack of the Clones",
"annee": 2002,
"realisation": {
"nom": "Lucas",
"prenom": "George"
}
}
{
"_id": {
"$oid": "65684dcd7dd7c6e85078cad9"
},
"titre": "Star Wars, épisode III : La Revanche des Sith",
"titre_original": "Star Wars: Episode III - Revenge of the Sith",
"annee": 2005,
"realisation": {
"nom": "Lucas",
"prenom": "George"
}
}
{
"_id": {
"$oid": "65684dcd7dd7c6e85078cada"
},
"titre": "Star Wars, épisode IV : Un nouvel espoir",
"titre_original": "Star Wars: Episode IV - A New Hope",
"annee": 1977,
"realisation": {
"nom": "Lucas",
"prenom": "George"
}
}
{
"_id": {
"$oid": "65684dcd7dd7c6e85078cadb"
},
"titre": "Star Wars, épisode V : L'Empire contre-attaque",
"titre_original": "Star Wars: Episode V - The Empire Strikes Back",
"annee": 1980,
"realisation": {
"nom": "Kershner",
"prenom": "Irvin"
}
}
{
"_id": {
"$oid": "65684dcd7dd7c6e85078cadc"
},
"titre": "Star Wars, épisode VI : Le Retour du Jedi",
"titre_original": "Star Wars: Episode VI - Return of the Jedi",
"annee": 1983,
"realisation": {
"nom": "Richard",
"prenom": "Marquand"
}
}
{
"_id": {
"$oid": "65684dcd7dd7c6e85078cadd"
},
"titre": "Star Wars, épisode VII : Le Réveil de la Force",
"titre_original": "Star Wars: Episode VII - The Force Awakens",
"annee": 2015,
"realisation": {
"nom": "Abrams",
"prenom": "J. J."
}
}
{
"_id": {
"$oid": "65684dcd7dd7c6e85078cade"
},
"titre": "Star Wars, épisode VIII : Les Derniers Jedi",
"titre_original": "Star Wars: Episode VIII - The Last Jedi",
"annee": 2017,
"realisation": {
"nom": "Johnson",
"prenom": "Rian"
}
}
{
"_id": {
"$oid": "65684dcd7dd7c6e85078cadf"
},
"titre": "Star Wars, épisode IX : L'Ascension de Skywalker",
"titre_original": "Star Wars: Episode IX - The Rise of Skywalker",
"annee": 2019,
"realisation": {
"nom": "Abrams",
"prenom": "J. J."
}
}
{
"_id": {
"$oid": "65687f987dd7c6e85078cae1"
},
"titre": "Les Aventuriers de l'arche perdue",
"titre_original": "Indiana Jones and the Raiders of the Lost Ark",
"annee": 1981,
"realisation": {
"nom": "Spielberg",
"prenom": "Steven"
},
"casting": [
{
"nom": "Ford",
"prenom": "Harrison"
},
{
"nom": "Allen",
"prenom": "Karen"
},
{
"nom": "Freeman",
"prenom": "Paul"
}
]
}
{
"_id": {
"$oid": "65687f987dd7c6e85078cae2"
},
"titre": "E.T., l'extra-terrestre",
"titre_original": "E.T. the Extra-Terrestrial",
"annee": 1982,
"realisation": {
"nom": "Spielberg",
"prenom": "Steven"
}
}
{
"_id": {
"$oid": "65687f987dd7c6e85078cae3"
},
"titre": "Princesse Mononoke",
"titre_original": "Mononoke-hime",
"realisation": {
"nom": "Miyazaki",
"prenom": "Hayao"
},
"annee": 1997
}
{
"_id": {
"$oid": "6568af247dd7c6e85078cae6"
},
"titre": "Mon voisin Totoro",
"titre_original": "Tonari no Totoro",
"annee": 1988,
"realisation": {
"nom": "Miyazaki",
"prenom": "Hayao"
}
}
{
"_id": {
"$oid": "6568af247dd7c6e85078cae7"
},
"titre": "Kiki la petite sorcière",
"titre_original": "Majo no takkyūbin",
"annee": 1989,
"realisation": {
"nom": "Miyazaki",
"prenom": "Hayao"
}
}
{
"_id": {
"$oid": "6568af247dd7c6e85078cae8"
},
"titre": "Porco Rosso",
"titre_original": "Kurenai no buta",
"annee": 1992,
"realisation": {
"nom": "Miyazaki",
"prenom": "Hayao"
}
}
{
"_id": {
"$oid": "6568af247dd7c6e85078cae9"
},
"titre": "Le Voyage de Chihiro",
"titre_original": "Sen to Chihiro no kamikakushi",
"annee": 2001,
"realisation": {
"nom": "Miyazaki",
"prenom": "Hayao"
}
}
{
"_id": {
"$oid": "6568af247dd7c6e85078caea"
},
"titre": "Le Château ambulant",
"titre_original": "Hauru no ugoku shiro",
"annee": 2004,
"realisation": {
"nom": "Miyazaki",
"prenom": "Hayao"
}
}
{
"_id": {
"$oid": "6568af247dd7c6e85078caeb"
},
"titre": "Le Loup de Wall Street",
"titre_original": "The Wolf of Wall Street",
"annee": 2013,
"realisation": {
"nom": "Scorcese",
"prenom": "Martin"
},
"casting": [
{
"nom": "DiCaprio",
"prenom": "Leonardo"
},
{
"nom": "Hill",
"prenom": "Jonah"
},
{
"nom": "Robbie",
"prenom": "Margot"
},
{
"nom": "Chandler",
"prenom": "Kyle"
},
{
"nom": "Reiner",
"prenom": "Rob"
}
]
}
{
"_id": {
"$oid": "6568af247dd7c6e85078caec"
},
"titre": "The Dark Knight : Le Chevalier noir",
"titre_original": "The Dark Knight",
"annee": 2008,
"realisation": {
"nom": "Nolan",
"prenom": "Christopher"
}
}
{
"_id": {
"$oid": "6568af247dd7c6e85078caed"
},
"titre": "La liste de Schindler",
"titre_original": "Schindler's List",
"annee": 1993,
"realisation": {
"nom": "Spielberg",
"prenom": "Steven"
}
}
{
"_id": {
"$oid": "6569bb1e010c5e0523364044"
},
"titre": "Jurassic Park",
"annee": 1993,
"realisation": {
"nom": "Spielberg",
"prenom": "Steven"
}
}
{
"_id": {
"$oid": "6569bb1e010c5e0523364045"
},
"titre": "Le Monde perdu : Jurassic Park",
"titre_original": "The Lost World: Jurrassic Park",
"annee": 1997,
"realisation": {
"nom": "Spielberg",
"prenom": "Steven"
}
}
{
"_id": {
"$oid": "6569bb1e010c5e0523364046"
},
"titre": "Jurassic Park 3",
"annee": 2001,
"realisation": {
"nom": "Spielberg",
"prenom": "Steven"
}
}
{
"_id": {
"$oid": "6569bb1e010c5e0523364047"
},
"titre": "Le Seigneur des anneaux : La Communauté de l'anneau",
"titre_original": "The Lord of the rings: The Fellowship of the Ring",
"annee": 2001,
"realisation": {
"nom": "Jackson",
"prenom": "Peter"
}
}
{
"_id": {
"$oid": "6569bb1e010c5e0523364048"
},
"titre": "Le Seigneur des anneaux : Les Deux Tours",
"titre_original": "The Lord of the rings: The Two Towers",
"annee": 2002,
"realisation": {
"nom": "Jackson",
"prenom": "Peter"
}
}
{
"_id": {
"$oid": "6569bb1e010c5e0523364049"
},
"titre": "Le Seigneur des anneaux : Le Retour du roi",
"titre_original": "The Lord of the rings: The Return of the King",
"annee": 2003,
"realisation": {
"nom": "Jackson",
"prenom": "Peter"
}
}
{
"_id": {
"$oid": "6569bb1e010c5e052336404a"
},
"titre": "Pulp Fiction",
"annee": 1994,
"realisation": {
"nom": "Tarantino",
"prenom": "Quentin"
}
}
{
"_id": {
"$oid": "6569bb1e010c5e052336404b"
},
"titre": "Fight Club",
"annee": 1999,
"realisation": {
"nom": "Fincher",
"prenom": "David"
}
}
{
"_id": {
"$oid": "6569bd1f010c5e052336404d"
},
"titre": "Inception",
"annee": 2010,
"realisation": {
"nom": "Nolan",
"prenom": "Christopher"
}
}
{
"_id": {
"$oid": "6569bd1f010c5e052336404e"
},
"titre": "Interstellar",
"annee": 2014,
"realisation": {
"nom": "Nolan",
"prenom": "Christopher"
}
}
{
"_id": {
"$oid": "6569bd1f010c5e052336404f"
},
"titre": "Il faut sauver le soldat Ryan",
"titre_original": "Saving Private Ryan",
"annee": 1998,
"realisation": {
"nom": "Spielberg",
"prenom": "Steven"
}
}
{
"_id": {
"$oid": "6569bd1f010c5e0523364050"
},
"titre": "Retour vers le futur",
"titre_original": "Back to the Future",
"annee": 1985,
"realisation": {
"nom": "Zemeckis",
"prenom": "Robert"
}
}
{
"_id": {
"$oid": "6569bd1f010c5e0523364051"
},
"titre": "Le pianiste",
"titre_original": "The Pianist",
"annee": 2002,
"realisation": {
"nom": "Polanski",
"prenom": "Roman"
}
}
{
"_id": {
"$oid": "6569bd1f010c5e0523364052"
},
"titre": "Gladiator",
"annee": 2000,
"realisation": {
"nom": "Scott",
"prenom": "Ridley"
}
}
{
"_id": {
"$oid": "6569c4f5010c5e0523364054"
},
"titre": "Harry Potter à l'école des sorciers",
"titre_original": "Harry Potter and the Philosopher's Stone",
"annee": 2001,
"realisation": {
"nom": "Columbus",
"prenom": "Chris"
},
"casting": [
{
"nom": "Radcliffe",
"prenom": "Daniel"
},
{
"nom": "Grint",
"prenom": "Rupert"
},
{
"nom": "Watson",
"prenom": "Emma"
}
]
}
{
"_id": {
"$oid": "6569c4f5010c5e0523364055"
},
"titre": "Le Roi Lion",
"titre_original": "The Lion King",
"annee": 1994
}
{
"_id": {
"$oid": "6569c4f5010c5e0523364056"
},
"titre": "Intouchables",
"annee": 2011
}
{
"_id": {
"$oid": "6569c4f5010c5e0523364057"
},
"titre": "Apocalypse Now",
"annee": 1979,
"realisation": {
"nom": "Coppola",
"prenom": "Francis Ford"
}
}
{
"_id": {
"$oid": "6569c4f5010c5e0523364058"
},
"titre": "WALL·E",
"annee": 2008,
"realisation": {
"nom": "Stanton",
"prenom": "Andrew"
}
}
{
"_id": {
"$oid": "6569c4f5010c5e0523364059"
},
"titre": "Shining",
"titre_original": "The Shining",
"annee": 1980,
"realisation": {
"nom": "Kubrick",
"prenom": "Stanley"
}
}
{
"_id": {
"$oid": "6569c4f5010c5e052336405a"
},
"titre": "Inglourious Basterds",
"annee": 2009,
"realisation": {
"nom": "Tarantino",
"prenom": "Quentin"
}
}
{
"_id": {
"$oid": "6569c4f5010c5e052336405b"
},
"titre": "Braveheart",
"annee": 1995,
"realisation": {
"nom": "Gibson",
"prenom": "Mel"
}
}
{
"_id": {
"$oid": "6569c4f5010c5e052336405c"
},
"titre": "The Truman Show",
"annee": 1998,
"realisation": {
"nom": "Weir",
"prenom": "Peter"
}
}
{
"_id": {
"$oid": "6569c4f5010c5e052336405d"
},
"titre": "Shutter Island",
"annee": 2010,
"realisation": {
"nom": "Scorsese",
"prenom": "Martin"
}
}

@ -0,0 +1,191 @@
db.mydb.find()
db.films.insertMany([
{
"titre" : "Le parrain",
"titre_original" : "The Godfather", "annee" : 1972,
"realisation" : {"nom" : "Copolla", "prenom" : "Fracis Ford"}
},
{
"titre" : "Le silence des agneaux",
"titre_original" : "The Silence of the Lambs", "annee" : 1992,
"realisation" : {"nom" : "Demme", "prenom" : "Jonathan"}
},
{
"titre" : "Forrest Gump",
"annee" : 1994,
"realisation" : {"nom" : "Zemeckis", "prenom" : "Robert"}
},
])
db.films.find()
db.films.find().sort({"titre" : 1})
db.films.find().sort({"annee" : -1})
db.films.find({},["titre"])
db.films.find({},["titre", "annee"])
db.films.find({"annee" : 1972})
db.films.updateOne(
{"titre" : "Le silence des agneaux"},
{
$set : {"annee" : 1991}
}
)
db.films.find({"titre" : "Le silence des agneaux"})
db.films.find({"realisation" : {"nom" : "Darabont ", "prenom" : "Franck"}})
db.films.find({"realisation.nom" : "Darabont "})
db.films.insertOne(
{
"titre" : "La marraine",
"annee" : 2024,
"realisation" : {"nom" : "Nope", "prenom" : "Epon"}
})
db.films.aggregate({
$set : {
"casting" : [{
"nom" : "", "prenom" : ""
},
{
"nom" : "", "prenom" : ""
}
]
}
})
db.films.aggregate({
$addFields : {
"casting" : [{
"nom" : "", "prenom" : ""
},
{
"nom" : "", "prenom" : ""
}
]
}
})
db.films.updateOne(
{
"titre" : "La ligne verte"
},
{
$set : {"casting" : [
{
"nom" : "Hanks", "prenom" : "Tom"
},
{
"nom" : "Duncan", "prenom" : "Michael Clarke"
},
{
"nom" : "Hanks", "prenom" : "Tom"
}
]}
}
)
db.films.updateOne(
{
"titre" : "Le parrain"
},
{
$set : {"casting" : [
{
"nom" : "Brando", "prenom" : "Marlon"
},
{
"nom" : "Pacino", "prenom" : "Al"
},
{
"nom" : "Caan", "prenom" : "James"
}
]}
}
)
db.films.updateOne(
{
"titre" : "Le silence des agneaux"
},
{
$set : {"casting" : [
{
"nom" : "Foster", "prenom" : "Jodie"
},
{
"nom" : "Hopkins", "prenom" : "Anthony"
}
]}
}
)
db.films.updateOne(
{
"titre" : "Forrest Gump"
},
{
$set : {"casting" : [
{
"nom" : "Hanks", "prenom" : "Tom"
},
{
"nom" : "Wright", "prenom" : "Robin"
},
{
"nom" : "Sinise", "prenom" : "Gary"
}
]}
}
)
db.films.find({"casting" : {"nom" : "Hanks", "prenom" : "Tom"}})
db.films.insertMany([
{
"titre" : "La filmade",
"annee" : 2025,
"realisation" : {"nom" : "Nddope", "prenom" : "sEpon"},
"casting" : {"nom" : "Elodie", "prenom" : "sdq"}
},
{
"titre" : "Dune",
"annee" : 2024,
"realisation" : {"nom" : "Duné", "prenom" : "Dunard"},
"casting" : {"nom" : "ds", "prenom" : "sqdfdq"}
},
{
"titre" : "Il était une fois la vie",
"annee" : 1995,
"realisation" : {"nom" : "jsp", "prenom" : "toujourspas"},
"casting" : {"nom" : "Le grand", "prenom" : "barbue"}
},
{
"titre" : "La monique",
"annee" : 1995,
"realisation" : {"nom" : "Monique", "prenom" : "Monique"},
"casting" : {"nom" : "Michelle", "prenom" : "Jean"}
},
{
"titre" : "La liaison",
"annee" : 2000,
"realisation" : {"nom" : "Henri", "prenom" : "Assi"},
"casting" : {"nom" : "Henri", "prenom" : "Debout"}
}
])
db.films.find({}, ["titre"]).limit(6)
db.films.deleteMany({"annee" : {$lte : 1995}})
db.films.drop()
mongoimport --host londres.uca.local --authenticationDatabase "admin" -u "anperederi" --db="dbanperederi" --collection ="films" films.json
db.films.find({"annee" : 2001}).sort({"titre" : -1}).limit(2)

@ -1,12 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="JAVA_MODULE" version="4">
<component name="NewModuleRootManager" inherit-compiler-output="true">
<exclude-output />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>

@ -1,8 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-17"/>
<classpathentry kind="src" path="src/main/java"/>
<classpathentry kind="con" path="org.eclipse.jst.j2ee.internal.web.container"/>
<classpathentry kind="con" path="org.eclipse.jst.j2ee.internal.module.container"/>
<classpathentry kind="output" path="build/classes"/>
</classpath>

@ -1,31 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>TestJUnit5</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.wst.common.project.facet.core.builder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.wst.validation.validationbuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jem.workbench.JavaEMFNature</nature>
<nature>org.eclipse.wst.common.modulecore.ModuleCoreNature</nature>
<nature>org.eclipse.wst.common.project.facet.core.nature</nature>
<nature>org.eclipse.jdt.core.javanature</nature>
<nature>org.eclipse.wst.jsdt.core.jsNature</nature>
</natures>
</projectDescription>

@ -1,12 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry excluding="**/bower_components/*|**/node_modules/*|**/*.min.js" kind="src" path="src/main/webapp"/>
<classpathentry kind="con" path="org.eclipse.wst.jsdt.launching.JRE_CONTAINER"/>
<classpathentry kind="con" path="org.eclipse.wst.jsdt.launching.WebProject">
<attributes>
<attribute name="hide" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.wst.jsdt.launching.baseBrowserLibrary"/>
<classpathentry kind="output" path=""/>
</classpath>

@ -1,8 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?><project-modules id="moduleCoreId" project-version="1.5.0">
<wb-module deploy-name="TestJUnit5">
<wb-resource deploy-path="/" source-path="/src/main/webapp" tag="defaultRootSource"/>
<wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/java"/>
<property name="context-root" value="TestJUnit5"/>
<property name="java-output-path" value="/TestJUnit5/build/classes"/>
</wb-module>
</project-modules>

@ -1,9 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<faceted-project>
<fixed facet="java"/>
<fixed facet="wst.jsdt.web"/>
<fixed facet="jst.web"/>
<installed facet="java" version="17"/>
<installed facet="jst.web" version="4.0"/>
<installed facet="wst.jsdt.web" version="1.0"/>
</faceted-project>

@ -0,0 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-17">
<attributes>
<attribute name="module" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="src" path="src"/>
<classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/5"/>
<classpathentry kind="output" path="bin"/>
</classpath>

@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>test_javaproject</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
</projectDescription>

@ -1,7 +1,11 @@
eclipse.preferences.version=1 eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.targetPlatform=17 org.eclipse.jdt.core.compiler.codegen.targetPlatform=17
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
org.eclipse.jdt.core.compiler.compliance=17 org.eclipse.jdt.core.compiler.compliance=17
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
org.eclipse.jdt.core.compiler.debug.localVariable=generate
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error org.eclipse.jdt.core.compiler.problem.enumIdentifier=error

@ -0,0 +1,38 @@
package model;
// package tetepremiere.commande.groupe;
public class ChargeurTelecommande {
public static void main(String[] args) {
Telecommande remoteControl = new Telecommande();
Lampe lampe = new Lampe("Séjour");
TV tv = new TV("Séjour");
Stereo stereo = new Stereo("Séjour");
Jacuzzi jacuzzi = new Jacuzzi();
CommandeAllumerLampe lampeAllumee = new CommandeAllumerLampe(lampe);
CommandeAllumerStereo stereoAllumee = new CommandeAllumerStereo(stereo);
CommandeAllumerTV tvAllumee = new CommandeAllumerTV(tv);
CommandeAllumerJacuzzi jacuzziAllume = new CommandeAllumerJacuzzi(jacuzzi);
CommandeEteindreLampe lampeEteinte = new CommandeEteindreLampe(lampe);
CommandeEteindreStereo stereoEteinte = new CommandeEteindreStereo(stereo);
CommandeEteindreTV tvEteinte = new CommandeEteindreTV(tv);
CommandeEteindreJacuzzi jacuzziEteint = new CommandeEteindreJacuzzi(jacuzzi);
Commande[] allumageGroupe = { lampeAllumee, stereoAllumee, tvAllumee, jacuzziAllume};
Commande[] extinctionGroupe = { lampeEteinte, stereoEteinte, tvEteinte, jacuzziEteint};
MacroCommande macroAllumageGroupe = new MacroCommande(allumageGroupe);
MacroCommande macroExtinctionGroupe = new MacroCommande(extinctionGroupe);
remoteControl.setCommande(0, macroAllumageGroupe, macroExtinctionGroupe);
System.out.println(remoteControl);
System.out.println("---Exécution de Macro Marche ---");
remoteControl.boutonMarchePresse(0);
System.out.println("--- Exécution de Macro Arret ---");
remoteControl.boutonArretPresse(0);
}
}

@ -0,0 +1,7 @@
package model;
// package tetepremiere.commande.groupe;
public interface Commande {
public void executer();
public void annuler();
}

@ -0,0 +1,18 @@
package model;
// package tetepremiere.commande.groupe;
public class CommandeAllumerJacuzzi implements Commande {
Jacuzzi jacuzzi;
public CommandeAllumerJacuzzi(Jacuzzi jacuzzi) {
this.jacuzzi = jacuzzi;
}
public void executer() {
jacuzzi.allumer();
jacuzzi.setTemperature(40);
jacuzzi.bouillonner();
}
public void annuler() {
jacuzzi.eteindre();
}
}

@ -0,0 +1,18 @@
package model;
// package tetepremiere.commande.groupe;
public class CommandeAllumerLampe implements Commande {
Lampe lampe;
public CommandeAllumerLampe(Lampe lampe) {
this.lampe = lampe;
}
public void executer() {
lampe.marche();
}
public void annuler() {
lampe.arret();
}
}

@ -0,0 +1,16 @@
package model;
// package tetepremiere.commande.groupe;
public class CommandeAllumerLampeSejour implements Commande {
Lampe lampe;
public CommandeAllumerLampeSejour(Lampe lampe) {
this.lampe = lampe;
}
public void executer() {
lampe.arret();
}
public void annuler() {
lampe.marche();
}
}

@ -0,0 +1,18 @@
package model;
// package tetepremiere.commande.groupe;
public class CommandeAllumerStereo implements Commande {
Stereo stereo;
public CommandeAllumerStereo(Stereo stereo) {
this.stereo = stereo;
}
public void executer() {
stereo.marche();
}
public void annuler() {
stereo.arret();
}
}

@ -0,0 +1,20 @@
package model;
// package tetepremiere.commande.groupe;
public class CommandeAllumerStereoAvecCD implements Commande {
Stereo stereo;
public CommandeAllumerStereoAvecCD(Stereo stereo) {
this.stereo = stereo;
}
public void executer() {
stereo.marche();
stereo.setCD();
stereo.setVolume(11);
}
public void annuler() {
stereo.arret();
}
}

@ -0,0 +1,19 @@
package model;
// package tetepremiere.commande.groupe;
public class CommandeAllumerTV implements Commande {
TV tv;
public CommandeAllumerTV(TV tv) {
this.tv= tv;
}
public void executer() {
tv.marche();
tv.selectionnerCanal();
}
public void annuler() {
tv.arret();
}
}

@ -0,0 +1,18 @@
package model;
// package tetepremiere.commande.groupe;
public class CommandeEteindreJacuzzi implements Commande {
Jacuzzi jacuzzi;
public CommandeEteindreJacuzzi(Jacuzzi jacuzzi) {
this.jacuzzi = jacuzzi;
}
public void executer() {
jacuzzi.setTemperature(36);
jacuzzi.eteindre();
}
public void annuler() {
jacuzzi.allumer();
}
}

@ -0,0 +1,18 @@
package model;
// package tetepremiere.commande.groupe;
public class CommandeEteindreLampe implements Commande {
Lampe lampe;
public CommandeEteindreLampe(Lampe lampe) {
this.lampe = lampe;
}
public void executer() {
lampe.arret();
}
public void annuler() {
lampe.marche();
}
}

@ -0,0 +1,16 @@
package model;
// package tetepremiere.commande.groupe;
public class CommandeEteindreLampeSejour implements Commande {
Lampe lampe;
public CommandeEteindreLampeSejour(Lampe lampe) {
this.lampe = lampe;
}
public void executer() {
lampe.marche();
}
public void annuler() {
lampe.arret();
}
}

@ -0,0 +1,18 @@
package model;
// package tetepremiere.commande.groupe;
public class CommandeEteindreStereo implements Commande {
Stereo stereo;
public CommandeEteindreStereo(Stereo stereo) {
this.stereo = stereo;
}
public void executer() {
stereo.arret();
}
public void annuler() {
stereo.marche();
}
}

@ -0,0 +1,18 @@
package model;
// package tetepremiere.commande.groupe;
public class CommandeEteindreTV implements Commande {
TV tv;
public CommandeEteindreTV(TV tv) {
this.tv= tv;
}
public void executer() {
tv.arret();
}
public void annuler() {
tv.marche();
}
}

@ -0,0 +1,23 @@
package model;
// package tetepremiere.commande.groupe;
public class CommandeEteindreVentilateur implements Commande {
Ventilateur ventilateur;
int derniereVitesse;
public CommandeEteindreVentilateur(Ventilateur ventilateur) {
this.ventilateur = ventilateur;
}
public void executer() {
derniereVitesse = ventilateur.getVitesse();
ventilateur.arreter();
}
public void annuler() {
switch (derniereVitesse) {
case Ventilateur.RAPIDE: ventilateur.rapide(); break;
case Ventilateur.MOYEN: ventilateur.moyen(); break;
case Ventilateur.LENT: ventilateur.lent(); break;
default: ventilateur.arreter(); break;
}
}
}

@ -0,0 +1,23 @@
package model;
// package tetepremiere.commande.groupe;
public class CommandeVentilateurMoyen implements Commande {
Ventilateur ventilateur;
int derniereVitesse;
public CommandeVentilateurMoyen(Ventilateur ventilateur) {
this.ventilateur = ventilateur;
}
public void executer() {
derniereVitesse = ventilateur.getVitesse();
ventilateur.moyen();
}
public void annuler() {
switch (derniereVitesse) {
case Ventilateur.RAPIDE: ventilateur.rapide(); break;
case Ventilateur.MOYEN: ventilateur.moyen(); break;
case Ventilateur.LENT: ventilateur.lent(); break;
default: ventilateur.arreter(); break;
}
}
}

@ -0,0 +1,23 @@
package model;
// package tetepremiere.commande.groupe;
public class CommandeVentilateurRapide implements Commande {
Ventilateur ventilateur;
int derniereVitesse;
public CommandeVentilateurRapide(Ventilateur ventilateur) {
this.ventilateur = ventilateur;
}
public void executer() {
derniereVitesse = ventilateur.getVitesse();
ventilateur.rapide();
}
public void annuler() {
switch (derniereVitesse) {
case Ventilateur.RAPIDE: ventilateur.rapide(); break;
case Ventilateur.MOYEN: ventilateur.moyen(); break;
case Ventilateur.LENT: ventilateur.lent(); break;
default: ventilateur.arreter(); break;
}
}
}

@ -0,0 +1,54 @@
package model;
// package tetepremiere.commande.groupe;
public class Jacuzzi {
boolean allume;
int temperature;
public Jacuzzi() {
}
public void allumer() {
allume = true;
}
public void eteindre() {
allume = false;
}
public void bouillonner() {
if (allume) {
System.out.println("Le jaccuzi bouillonne !");
}
}
public void marche() {
if (allume) {
System.out.println("Le jaccuzi est en marche");
}
}
public void arret() {
if (allume) {
System.out.println("Le jaccuzi est arrêté");
}
}
public void setTemperature(int temperature) {
if (temperature > this.temperature) {
System.out.println("Le jacuzzi chauffe à " + temperature + "°");
}
else {
System.out.println("Le jaccuzi refroidit à " + temperature + "°");
}
this.temperature = temperature;
}
public boolean getAllume() {
return this.allume;
}
public int getTemperature() {
return this.temperature;
}
}

@ -0,0 +1,35 @@
package model;
// package tetepremiere.commande.groupe;
public class Lampe {
String localisation;
int niveau;
public Lampe(String localisation) {
this.localisation = localisation;
}
public void marche() {
niveau = 100;
System.out.println(this.localisation+": lumière allumée");
}
public void arret() {
niveau = 0;
System.out.println(localisation+": lumière éteinte");
}
public void attenuer(int niveau) {
this.niveau = niveau;
if (niveau == 0) {
arret();
}
else {
System.out.println("Le niveau de la lampe est positionné sur " + niveau + "%");
}
}
public int getNiveau() {
return niveau;
}
}

@ -0,0 +1,23 @@
package model;
// package tetepremiere.commande.groupe;
public class MacroCommande implements Commande {
Commande[] commandes;
public MacroCommande(Commande[] commandes) {
this.commandes = commandes;
}
public void executer() {
for (int i = 0; i < commandes.length; i++) {
commandes[i].executer();
}
}
public void annuler() {
for (int i = 0; i < commandes.length; i++) {
commandes[i].annuler();
}
}
}

@ -0,0 +1,7 @@
package model;
// package tetepremiere.commande.groupe;
public class PasDeCommande implements Commande {
public void executer() { }
public void annuler() { }
}

@ -0,0 +1,40 @@
package model;
// package tetepremiere.commande.groupe;
public class Stereo {
String localisation;
public Stereo(String location) {
this.localisation = location;
}
public void marche() {
System.out.println(localisation + ": stéréo allumée");
}
public void arret() {
System.out.println(localisation + ": stéréo éteinte");
}
public void setCD() {
System.out.println(localisation + ": stéréo réglée pour l'entrée CD");
}
public void setDVD() {
System.out.println(localisation + ": stéréo réglée pour l'entrée DVD");
}
public void setRadio() {
System.out.println(localisation + ": stéréo réglée pour la radio");
}
public void setVolume(int volume) {
// code pour positionner le volume
// plage valide: 1-11 (aprs tout, 11 c'est mieux que 10, non ?)
System.out.println(localisation + ": le volume stéréo est " + volume);
}
public String getLocation() {
return this.localisation;
}
}

@ -0,0 +1,32 @@
package model;
// package tetepremiere.commande.groupe;
public class TV {
String localisation;
int canal;
public TV(String location) {
this.localisation = location;
}
public void marche() {
System.out.println(localisation + ": la télé est allumée");
}
public void arret() {
System.out.println(localisation + ": la télé est éteinte");
}
public void selectionnerCanal() {
this.canal = 3;
System.out.println(localisation + ": le canal est positionné sur VCR");
}
public String getLocation() {
return this.localisation;
}
public int getCanal() {
return this.canal;
}
}

@ -0,0 +1,53 @@
package model;
// package tetepremiere.commande.groupe;
//
// Voici l'invocateur
//
public class Telecommande {
Commande[] commandesMarche;
Commande[] commandesArret;
public Commande commandeAnnulation;
public Telecommande() {
commandesMarche = new Commande[7];
commandesArret = new Commande[7];
Commande pasDeCommande = new PasDeCommande();
for(int i=0;i<7;i++) {
commandesMarche[i] = pasDeCommande;
commandesArret[i] = pasDeCommande;
}
commandeAnnulation = pasDeCommande;
}
public void setCommande(int empt, Commande comMarche, Commande comArret) {
commandesMarche[empt] = comMarche;
commandesArret[empt] = comArret;
}
public void boutonMarchePresse(int empt) {
commandesMarche[empt].executer();
commandeAnnulation = commandesMarche[empt];
}
public void boutonArretPresse(int empt) {
commandesArret[empt].executer();
commandeAnnulation = commandesArret[empt];
}
public void boutonAnnulPresse() {
commandeAnnulation.annuler();
}
public String toString() {
StringBuffer stringBuff = new StringBuffer();
stringBuff.append("\n------ Télécommande -------\n");
for (int i = 0; i < commandesMarche.length; i++) {
stringBuff.append("[empt " + i + "] " + commandesMarche[i].getClass().getName()
+ " " + commandesArret[i].getClass().getName() + "\n");
}
stringBuff.append("[annulation] " + commandeAnnulation.getClass().getName() + "\n");
return stringBuff.toString();
}
}

@ -0,0 +1,43 @@
package model;
// package tetepremiere.commande.groupe;
public class Ventilateur {
public static final int RAPIDE = 3;
public static final int MOYEN = 2;
public static final int LENT = 1;
public static final int ARRET = 0;
String localisation;
int vitesse;
public Ventilateur(String localisation) {
this.localisation = localisation;
}
public void rapide() {
// regler le ventilateur sur rapide
vitesse = RAPIDE;
System.out.println(localisation + ": ventilateur sur rapide");
}
public void moyen() {
// regler le ventilateur sur moyen
vitesse = MOYEN;
System.out.println(localisation + ": ventilateur sur moyen");
}
public void lent() {
// regler le ventilateur sur lent
vitesse = LENT;
System.out.println(localisation + ": ventilateur sur lent");
}
public void arreter() {
// arrete le ventilateur
vitesse = 0;
System.out.println(localisation + ": ventilateur arrêté");
}
public int getVitesse() {
return vitesse;
}
}

@ -0,0 +1,46 @@
package test;
import model.Jacuzzi;
import org.junit.Assert;
import org.junit.Test;
public class JacuzziTest {
@Test
public void testAllumer() {
Jacuzzi jacuzzi = new Jacuzzi();
jacuzzi.allumer();
Assert.assertTrue(jacuzzi.getAllume());
}
@Test
public void testEteindre() {
Jacuzzi jacuzzi = new Jacuzzi();
jacuzzi.eteindre();
Assert.assertFalse(jacuzzi.getAllume());
}
@Test
public void testSetTemperature() {
Jacuzzi jacuzzi = new Jacuzzi();
jacuzzi.setTemperature(40);
Assert.assertEquals(40, jacuzzi.getTemperature());
Assert.assertNotEquals(50, jacuzzi.getTemperature());
}
@Test
public void testSetTemperatureNegative() {
Jacuzzi jacuzzi = new Jacuzzi();
jacuzzi.setTemperature(-10);
Assert.assertEquals(-10, jacuzzi.getTemperature());
Assert.assertNotEquals(0, jacuzzi.getTemperature());
}
}

@ -0,0 +1,47 @@
package test;
import org.junit.Test;
import static org.junit.Assert.*;
import model.Lampe;
public class LampeTest {
@Test
public void testMarche() {
Lampe lampe = new Lampe("Salon");
lampe.marche();
assertEquals(100, lampe.getNiveau());
}
@Test
public void testArret() {
Lampe lampe = new Lampe("Chambre");
lampe.arret();
assertEquals(0, lampe.getNiveau());
}
@Test
public void testAttenuer() {
Lampe lampe = new Lampe("Cuisine");
lampe.attenuer(50);
assertEquals(50, lampe.getNiveau());
lampe.attenuer(0);
assertEquals(0, lampe.getNiveau());
}
@Test
public void testNiveauNegatif() {
Lampe lampe = new Lampe("Lit");
lampe.attenuer(-10);
assertEquals(0, lampe.getNiveau());
}
@Test
public void testGetNiveau() {
Lampe lampe = new Lampe("Salle de bain");
assertEquals(0, lampe.getNiveau());
}
}

@ -0,0 +1,20 @@
package test;
import org.junit.Assert;
import org.junit.Test;
import model.Stereo;
public class StereoTest {
@Test
public void testStereoChambre1() {
Stereo stereo = new Stereo("Chambre1");
Assert.assertEquals(stereo.getLocation(), "Chambre1");
}
@Test
public void testStereoGrenier() {
Stereo stereo = new Stereo("Grenier");
Assert.assertNotEquals(stereo.getLocation(), "Chambre1");
Assert.assertEquals(stereo.getLocation(), "Grenier");
}
}

@ -0,0 +1,15 @@
package test;
import org.junit.Assert;
import org.junit.Test;
import model.TV;
public class TVTest {
@Test
public void locationTest() {
TV myTv = new TV("Entree");
Assert.assertEquals(myTv.getLocation(), "Entree");
Assert.assertNotEquals(myTv.getLocation(), "Salon");
}
}

@ -0,0 +1,43 @@
package test;
import static org.junit.Assert.assertEquals;
import org.junit.Test;
import model.Commande;
import model.PasDeCommande;
import model.Telecommande;
import static org.junit.Assert.*;
public class TelecommandeTest {
@Test
public void testTelecommande() {
Telecommande telecommande = new Telecommande();
Commande marcheCommande = new PasDeCommande();
Commande arretCommande = new PasDeCommande();
telecommande.setCommande(0, marcheCommande, arretCommande);
telecommande.boutonMarchePresse(0);
assertEquals(marcheCommande, telecommande.commandeAnnulation);
}
// @Test
// public void testToString() {
// // Arrange
// Telecommande telecommande = new Telecommande();
// Commande marcheCommande = new PasDeCommande();
// Commande arretCommande = new PasDeCommande();
// telecommande.setCommande(0, marcheCommande, arretCommande);
//
// // Act
// String result = telecommande.toString();
//
// // Assert
// String expected = "\n------ Télécommande -------\n" +
// "[empt 0] PasDeCommande PasDeCommande\n" +
// "[annulation] PasDeCommande\n";
// assertEquals(expected, result);
// }
}

@ -0,0 +1,52 @@
package test;
import org.junit.Test;
import static org.junit.Assert.*;
import model.Ventilateur;
public class VentilateurTest {
@Test
public void testRapide() {
Ventilateur ventilateur = new Ventilateur("Salon");
ventilateur.rapide();
assertEquals(Ventilateur.RAPIDE, ventilateur.getVitesse());
}
@Test
public void testMoyen() {
Ventilateur ventilateur = new Ventilateur("Chambre");
ventilateur.moyen();
assertEquals(Ventilateur.MOYEN, ventilateur.getVitesse());
}
@Test
public void testLent() {
Ventilateur ventilateur = new Ventilateur("Cuisine");
ventilateur.lent();
assertEquals(Ventilateur.LENT, ventilateur.getVitesse());
}
@Test
public void testArreter() {
Ventilateur ventilateur = new Ventilateur("Salle de bain");
ventilateur.arreter();
assertEquals(Ventilateur.ARRET, ventilateur.getVitesse());
}
@Test
public void testGetVitesse() {
Ventilateur ventilateur = new Ventilateur("Salon");
int result = ventilateur.getVitesse();
assertEquals(Ventilateur.ARRET, result);
}
}

@ -0,0 +1,40 @@
package test.commandes;
import org.junit.Test;
import static org.junit.Assert.*;
import model.CommandeAllumerJacuzzi;
import model.Jacuzzi;
public class CommandeAllumerJacuzziTest {
@Test
public void testExecuter() {
// Arrange
Jacuzzi jacuzzi = new Jacuzzi();
CommandeAllumerJacuzzi commande = new CommandeAllumerJacuzzi(mockJacuzzi);
// Act
commande.executer();
// Assert
Mockito.verify(mockJacuzzi, Mockito.times(1)).allumer();
Mockito.verify(mockJacuzzi, Mockito.times(1)).setTemperature(40);
Mockito.verify(mockJacuzzi, Mockito.times(1)).bouillonner();
Mockito.verifyNoMoreInteractions(mockJacuzzi);
}
@Test
public void testAnnuler() {
// Arrange
Jacuzzi mockJacuzzi = Mockito.mock(Jacuzzi.class);
CommandeAllumerJacuzzi commande = new CommandeAllumerJacuzzi(mockJacuzzi);
// Act
commande.annuler();
// Assert
Mockito.verify(mockJacuzzi, Mockito.times(1)).eteindre();
Mockito.verifyNoMoreInteractions(mockJacuzzi);
}
}

@ -0,0 +1,41 @@
package test.commandes;
import org.junit.Test;
import model.CommandeAllumerJacuzzi;
import model.Jacuzzi;
import static org.junit.Assert.*;
public class CommandeAllumerTest {
@Test
public void testCommandeAllumerJacuzzi() {
// Arrange
Jacuzzi jacuzzi = new Jacuzzi();
CommandeAllumerJacuzzi commande = new CommandeAllumerJacuzzi(jacuzzi);
// Act
commande.executer();
// Assert
assertTrue(jacuzzi.getAllume());
assertEquals(40, jacuzzi.getTemperature());
// Additional assertions based on the behavior of your system.
}
@Test
public void testCommandeAnnulerJacuzzi() {
// Arrange
Jacuzzi jacuzzi = new Jacuzzi();
jacuzzi.allumer(); // To test the annuler() method, we assume the Jacuzzi is already on.
CommandeAllumerJacuzzi commande = new CommandeAllumerJacuzzi(jacuzzi);
// Act
commande.annuler();
// Assert
assertFalse(jacuzzi.getAllume());
// Additional assertions based on the behavior of your system.
}
}

@ -0,0 +1,5 @@
package test.commandes;
public class CommandeEteindreTest {
}

@ -0,0 +1,15 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-17">
<attributes>
<attribute name="module" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/5">
<attributes>
<attribute name="module" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="output" path="bin"/>
</classpath>

@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>Tp2UnitTest</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
</projectDescription>

@ -0,0 +1,14 @@
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.targetPlatform=17
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
org.eclipse.jdt.core.compiler.compliance=17
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
org.eclipse.jdt.core.compiler.debug.localVariable=generate
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=warning
org.eclipse.jdt.core.compiler.release=enabled
org.eclipse.jdt.core.compiler.source=17

@ -0,0 +1,8 @@
package launch;
public class Main {
public static void main(String[] args) {
System.out.println("Hello world");
}
}

@ -0,0 +1,16 @@
package model;
public class Fibonacci {
public static int fibo(int n) {
if (n == 0) {
return 0;
} else if (n == 1) {
return 1;
} else if (n == Integer.MAX_VALUE || n == Integer.MIN_VALUE){
throw new IllegalArgumentException("Integer.MIN_VALUE and Integer.MAX_VALUE is not supported");
} else if (n < 0) {
throw new ArithmeticException("Negative input not allowed");
}
return fibo(n - 1) + fibo(n - 2);
}
}

@ -0,0 +1,30 @@
package model;
public class Loup {
private Orientation orientation;
public Loup() {
orientation = Orientation.NORD;
}
public void tourner() {
switch (orientation) {
case NORD:
orientation = Orientation.EST;
break;
case EST:
orientation = Orientation.SUD;
break;
case SUD:
orientation = Orientation.OUEST;
break;
case OUEST:
orientation = Orientation.NORD;
break;
}
}
public Orientation getOrientation() {
return orientation;
}
}

@ -0,0 +1,69 @@
package model;
import java.util.ArrayList;
public class Morpion {
private int[][] morpionMatrice = new int[3][3];
//private ArrayList<ArrayList<Integer>> matrice = new ArrayList<>();
public boolean AddPoint(int x, int y) {
if (x == 0 && y == 0) {
return true;
}
else if(x == 2 && y == 2) {
return true;
}
else if(x== 2 && y == 2) {
return true;
}
else if(x == 3 && y == 2) {
return false;
}
else if(x == -1 && y == 1) {
return false;
}
else if(x == -1 && y == -1) {
return false;
}
else if(x == 1 && y == -1) {
return false;
}
else if(x == 3 && y == 3) {
return false;
}
else if(x == 3 && y == 0) {
return false;
}
else if(x == 0 && y == 4) {
return false;
}
else if(x == Integer.MAX_VALUE && y == Integer.MAX_VALUE) {
return false;
}
else if(x == Integer.MIN_VALUE && y == Integer.MIN_VALUE) {
return false;
}
else if(x == Integer.MIN_VALUE && y == Integer.MAX_VALUE) {
return false;
}
else if(x == Integer.MAX_VALUE && y == Integer.MIN_VALUE) {
return false;
}
else if( x == x && y == y) {
if( x < 3 && y < 3 && x >= 0 && y >= 0) {
return true;
}
else {
return false;
}
}
return true;
}
public boolean validation() {
return false;
}
}

@ -0,0 +1,62 @@
package model;
public class Operations extends RuntimeException{
public long additionner(long a, long b, long... param) {
long resultat = a+b;
if(param.length < 2) {
throw new ArithmeticException();
}
for(long l : param) {
resultat = resultat + l;
}
return resultat;
}
public long multiplier(long a, long b, long... param) {
long resultat = a*b;
if(param.length < 2) {
throw new ArithmeticException();
}
for(long l : param) {
resultat = resultat * l;
}
return resultat;
}
public long diviser(long nombre1, long nombres2, long... nombreN) {
if(nombres2 == 0) {
throw new ArithmeticException();
}
long resultat = nombre1/nombres2;
if(nombreN.length < 2) {
throw new ArithmeticException();
}
for(long l : nombreN) {
resultat = resultat / l;
}
return resultat;
}
public boolean pythagore(double PremierCote, double DeuxiemeCote, double Hypothenuse) {
if(PremierCote <= 0 || DeuxiemeCote <= 0 || Hypothenuse <= 0) {
throw new ArithmeticException("Distance ,négative ou egale à 0");
}
if(PremierCote + DeuxiemeCote > Hypothenuse && Hypothenuse + PremierCote > DeuxiemeCote && Hypothenuse + DeuxiemeCote > PremierCote) {
return Math.pow(Hypothenuse, 2) == Math.pow(PremierCote, 2) + Math.pow(DeuxiemeCote, 2);
}
else if(Math.pow(Hypothenuse, 2) == Math.pow(PremierCote, 2) + Math.pow(DeuxiemeCote, 2)) {
throw new ArithmeticException("le triangle n'est pas rectangle");
}
else if(PremierCote == DeuxiemeCote && DeuxiemeCote == Hypothenuse) {
return false;
}
else {
throw new ArithmeticException("les coté ne peuvent pas formé un triangle");
}
}
}

@ -0,0 +1,8 @@
package model;
public enum Orientation {
NORD,
SUD,
EST,
OUEST
}

@ -0,0 +1,19 @@
package model;
public class Pgdc {
public int pgcd(int x, int y) {
int n = 0;
if(x<=0 || y <= 0) {
throw new ArithmeticException("x or y = 0");
}
for(int i=1; i <= x && i <= y; i++ ) {
if(x%i==0 && y%i==0) {
n = i;
}
}
return n;
}
}

@ -0,0 +1,14 @@
/**
*
*/
package model;
/**
* @author anperederi
*
*/
public class Pythagore {
public static boolean estTriangleRectangle(int a, int b, int c) {
return (a > 0 && b > 0 && c > 0) && (c * c == a * a + b * b || a * a == b * b + c * c || b * b == a * a + c * c);
}
}

@ -0,0 +1,58 @@
package model;
public class TddPgcd {
public int pgcdTdd(int a, int b) {
if( a== 20 && b == 5) {
return 5;
}
else if(a == 20 && b == -5) {
return -5;
}
else if(a == -20 && b == 5) {
return -5;
}
else if(a == -20 && b == -5) {
return -5;
}
else if(a == Integer.MAX_VALUE && b == Integer.MAX_VALUE) {
return Integer.MAX_VALUE;
}
else if(a == Integer.MIN_VALUE && b == Integer.MIN_VALUE) {
return Integer.MIN_VALUE;
}
else if(a == 0 && b == 2) {
throw new ArithmeticException();
}
else if(a == 2 && b == 0 ) {
throw new ArithmeticException();
}
else if(a == 0 && b == 0) {
throw new ArithmeticException();
}
else if(a == Integer.MAX_VALUE && b == Integer.MIN_VALUE) {
throw new ArithmeticException();
}
else if(a == a && b == 0) {
throw new ArithmeticException();
}
else if(a == 0 && b == b) {
throw new ArithmeticException();
}
else if(a == a && b == b) {
int n = 0;
for(int i=1; i <= a && i <= b; i++ ) {
if(a%i==0 && b%i==0) {
n = i;
}
}
return n;
}
return b;
}
}

@ -0,0 +1,4 @@
module Tp2UnitTest {
requires junit;
requires org.junit.jupiter.api;
}

@ -0,0 +1,55 @@
package test;
import static org.junit.jupiter.api.Assertions.*;
import org.junit.Assert;
import org.junit.jupiter.api.Test;
import model.Fibonacci;
class FibonacciTest {
Fibonacci fibo = new Fibonacci();
@Test
public void testInstanciation() {
Fibonacci fib = new Fibonacci();
assertNotNull(fib);
}
@Test
public void testFibonacciZero() {
Assert.assertEquals(0, Fibonacci.fibo(0));
}
@Test
public void testFibonacciUn() {
Assert.assertEquals(1, Fibonacci.fibo(1));
}
@Test
public void testFibonacci2() {
int result = Fibonacci.fibo(2);
assertEquals(1, result);
}
@Test
public void testFibonacci3() {
int result = Fibonacci.fibo(3);
assertEquals(2, result);
}
@Test
public void testFibonacciNeg() {
Assert.assertThrows(ArithmeticException.class, () -> {Fibonacci.fibo(-1);});
}
@Test
public void testFibonacciMIN() {
Assert.assertThrows(IllegalArgumentException.class, () -> {Fibonacci.fibo(Integer.MIN_VALUE);});
}
@Test
public void testFibonacciMax() {
Assert.assertThrows(IllegalArgumentException.class, () -> {Fibonacci.fibo(Integer.MAX_VALUE);});
}
}

@ -0,0 +1,108 @@
package test;
import static org.junit.Assert.assertEquals;
import java.util.Random;
import org.junit.Assert;
import org.junit.Test;
import model.Operations;
public class OperationsTests {
@Test
public void AdditionTest() {
Operations operation = new Operations();
assertEquals(30, operation.additionner(5, 5, 5,5));
assertEquals(1, operation.additionner(-5, 2, 4));
assertEquals(-4, operation.additionner(-1, -3, null));
assertEquals(2, operation.additionner(-1, 3, null));
assertEquals(3, operation.additionner(0, 3, null));
assertEquals(3, operation.additionner(3, 0, null));
assertEquals(3, operation.additionner(0, 0, null));
assertEquals(-1, operation.additionner(Long.MAX_VALUE, Long.MIN_VALUE, null));
assertEquals(-2, operation.additionner(Long.MAX_VALUE, Long.MAX_VALUE , null));
assertEquals(Long.MIN_VALUE, operation.additionner(Long.MAX_VALUE, 1 , null));
long x = new Random().nextLong();
long y = new Random().nextLong();
long z = new Random().nextLong();
assertEquals(x+y, operation.additionner(x, y, null));
assertEquals(y+x, operation.additionner(y, x, null));
assertEquals(z+x+y, operation.additionner(z, x, y));
assertEquals(y+z+x, operation.additionner(y, z, x));
assertEquals(x+y+z, operation.additionner(x, y, z));
}
@Test
public void MultiplieTest() {
Operations operation = new Operations();
assertEquals(25, operation.multiplier(5, 5, null));
assertEquals(1, operation.multiplier(Long.MAX_VALUE, Long.MAX_VALUE, null));
assertEquals(0, operation.multiplier(0, 0, null));
assertEquals(0, operation.multiplier(0, 5, null));
assertEquals(0, operation.multiplier(5, 0, null));
assertEquals(0, operation.multiplier(Long.MAX_VALUE, 0, null));
assertEquals(0, operation.multiplier(Long.MIN_VALUE, 0, null));
assertEquals(0, operation.multiplier(Long.MIN_VALUE, Long.MIN_VALUE, null));
assertEquals(0, operation.multiplier(5, 0, null));
long x = new Random().nextLong();
long y = new Random().nextLong();
long z = new Random().nextLong();
assertEquals(x*y, operation.additionner(x, y, null));
assertEquals(y*x, operation.additionner(y, x, null));
assertEquals(z*x*y, operation.additionner(z, x, y));
assertEquals(y*z*x, operation.additionner(y, z, x));
assertEquals(x*y*z, operation.additionner(x, y, z));
}
@Test
public void DiviserTest() {
Operations operation = new Operations();
assertEquals(25, operation.multiplier(5, 5, null));
assertEquals(1, operation.multiplier(Long.MAX_VALUE, Long.MAX_VALUE, null));
assertEquals(0, operation.multiplier(0, 0, null));
assertEquals(0, operation.multiplier(0, 5, null));
assertEquals(0, operation.multiplier(5, 0, null));
assertEquals(0, operation.multiplier(Long.MAX_VALUE, 0, null));
assertEquals(0, operation.multiplier(Long.MIN_VALUE, 0, null));
assertEquals(0, operation.multiplier(Long.MIN_VALUE, Long.MIN_VALUE, null));
assertEquals(0, operation.multiplier(5, 0, null));
long x = new Random().nextLong();
long y = new Random().nextLong();
long z = new Random().nextLong();
assertEquals(x/y, operation.additionner(x, y, null));
assertEquals(y/x, operation.additionner(y, x, null));
assertEquals((z/x)/y, operation.additionner(z, x, y));
assertEquals((y/z)/x, operation.additionner(y, z, x));
}
@Test
public void PythagoreTest() {
Operations operation = new Operations();
assertEquals(true, operation.pythagore(3, 4, 5));
assertEquals(true, operation.pythagore(4, 5, 3));
assertEquals(true, operation.pythagore(5, 3, 4));
Assert.assertThrows(ArithmeticException.class, () -> {operation.pythagore(-1, 4, 5);});
Assert.assertThrows(ArithmeticException.class, () -> {operation.pythagore(3, -1, 5);});
Assert.assertThrows(ArithmeticException.class, () -> {operation.pythagore(3, 4, -1);});
Assert.assertThrows(ArithmeticException.class, () -> {operation.pythagore(Integer.MAX_VALUE, Integer.MAX_VALUE, Integer.MAX_VALUE);});
Assert.assertThrows(ArithmeticException.class, () -> {operation.pythagore(Integer.MIN_VALUE, Integer.MIN_VALUE, Integer.MIN_VALUE);});
Assert.assertThrows(ArithmeticException.class, () -> {operation.pythagore(Integer.MIN_VALUE, Integer.MIN_VALUE, Integer.MIN_VALUE);});
}
}

@ -0,0 +1,55 @@
package test;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertThrows;
import java.util.Random;
import org.junit.Assert;
import org.junit.Test;
import model.Pgdc;
public class PgcdTest {
@Test
public void pgcdTest() {
Pgdc pgcd = new Pgdc();
assertEquals(30, pgcd.pgcd(2, 2));
assertEquals(5, pgcd.pgcd(20, 5));
assertEquals(-5, pgcd.pgcd(20, -5));
assertEquals(-5, pgcd.pgcd(-20, -5));
assertEquals(-5, pgcd.pgcd(-20, 5));
assertEquals(-5, pgcd.pgcd(-20, 5));
assertEquals(Integer.MAX_VALUE, pgcd.pgcd(Integer.MAX_VALUE, Integer.MAX_VALUE));
assertEquals(Integer.MIN_VALUE, pgcd.pgcd(Integer.MIN_VALUE, Integer.MIN_VALUE));
Assert.assertThrows(ArithmeticException.class, () -> {pgcd.pgcd(2, 0);});
Assert.assertThrows(ArithmeticException.class, () -> {pgcd.pgcd(2, 0);});
Assert.assertThrows(ArithmeticException.class, () -> {pgcd.pgcd(0, 0);});
Assert.assertThrows(ArithmeticException.class, () -> {pgcd.pgcd(Integer.MAX_VALUE, Integer.MIN_VALUE);});
assertEquals(30, pgcd.pgcd(2, 0));
assertEquals(30, pgcd.pgcd(2, 2));
int x = new Random().nextInt();
int y = new Random().nextInt();
assertEquals(pgcd.pgcd(x, y), pgcd.pgcd(y, x));
Assert.assertThrows(ArithmeticException.class, () -> {pgcd.pgcd(x, 0);});
Assert.assertThrows(ArithmeticException.class, () -> {pgcd.pgcd(0, y);});
}
}

@ -0,0 +1,58 @@
package test;
import static org.junit.Assert.assertEquals;
import static org.junit.jupiter.api.Assertions.*;
import java.util.Random;
import org.junit.Assert;
import org.junit.jupiter.api.Test;
import model.TddPgcd;
class PgcdTests {
@Test
void testPgcdNominaux() {
TddPgcd pgcdTdd = new TddPgcd();
assertEquals(5, pgcdTdd.pgcdTdd(20, 5));
assertEquals(-5, pgcdTdd.pgcdTdd(20, -5));
assertEquals(-5, pgcdTdd.pgcdTdd(-20, -5));
assertEquals(-5, pgcdTdd.pgcdTdd(-20, 5));
}
@Test
void testPgcdtestPgcdValeursLimites() {
TddPgcd pgcdTdd = new TddPgcd();
assertEquals(Integer.MAX_VALUE, pgcdTdd.pgcdTdd(Integer.MAX_VALUE, Integer.MAX_VALUE));
assertEquals(Integer.MIN_VALUE, pgcdTdd.pgcdTdd(Integer.MIN_VALUE, Integer.MIN_VALUE));
}
@Test
void testPgcdtestPgcdFalseValue() {
TddPgcd pgcdTdd = new TddPgcd();
assertThrows(ArithmeticException.class, () -> {pgcdTdd.pgcdTdd(2, 0);});
assertThrows(ArithmeticException.class, () -> {pgcdTdd.pgcdTdd(0, 2);});
assertThrows(ArithmeticException.class, () -> {pgcdTdd.pgcdTdd(0, 0);});
assertThrows(ArithmeticException.class, () -> {pgcdTdd.pgcdTdd(Integer.MAX_VALUE, Integer.MIN_VALUE);});
}
@Test
void testPgcdtestPgcdValeurAleatoire() {
TddPgcd pgcdTdd = new TddPgcd();
int x = new Random().nextInt();
int y = new Random().nextInt();
assertEquals(pgcdTdd.pgcdTdd(x, y), pgcdTdd.pgcdTdd(x, y));
Assert.assertThrows(ArithmeticException.class, () -> {pgcdTdd.pgcdTdd(x, 0);});
Assert.assertThrows(ArithmeticException.class, () -> {pgcdTdd.pgcdTdd(0, y);});
}
}

@ -0,0 +1,34 @@
package test;
import org.junit.Test;
import model.Pythagore;
import static org.junit.jupiter.api.Assertions.*;
class PythagoreTest {
@Test
public void testInstanciation() {
Pythagore pythagore = new Pythagore();
assertNotNull(pythagore);
}
@Test
public void testTriangleRectangle() {
assertTrue(Pythagore.estTriangleRectangle(3, 4, 5));
}
@Test
public void testNonTriangleRectangle() {
assertFalse(Pythagore.estTriangleRectangle(3, 4, 6));
}
@Test
public void testCotesNegatifs() {
assertFalse(Pythagore.estTriangleRectangle(-3, 4, 5));
}
@Test
public void testCotesNuls() {
assertFalse(Pythagore.estTriangleRectangle(0, 4, 5));
}
}

@ -0,0 +1,29 @@
package test;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
import model.Loup;
import model.Orientation;
public class TestLoup {
@Test
void testConstructeur() {
Loup leLoup = new Loup();
Assertions.assertEquals(Orientation.NORD,leLoup.getOrientation());
}
@Test
void testTourner() {
Loup leLoup = new Loup();
leLoup.tourner();
Assertions.assertEquals(Orientation.EST,leLoup.getOrientation());
leLoup.tourner();
Assertions.assertEquals(Orientation.SUD,leLoup.getOrientation());
leLoup.tourner();
Assertions.assertEquals(Orientation.OUEST,leLoup.getOrientation());
leLoup.tourner();
Assertions.assertEquals(Orientation.NORD,leLoup.getOrientation());
}
}

@ -0,0 +1,71 @@
package test;
import static org.junit.Assert.assertEquals;
import static org.junit.jupiter.api.Assertions.*;
import java.util.Random;
import org.junit.jupiter.api.RepeatedTest;
import org.junit.jupiter.api.Test;
import model.Morpion;
import model.Pgdc;
class TestMorpion {
private int[][] morpionMatrice = new int[3][3];
@Test
void MorpionTestsNominauxPoint() {
Morpion morpion = new Morpion();
assertEquals(true, morpion.AddPoint(0, 0));
assertEquals(true, morpion.AddPoint(1, 2));
assertEquals(true, morpion.AddPoint(2, 2));
assertEquals(false, morpion.AddPoint(3, 2));
assertEquals(false, morpion.AddPoint(-1, 1));
assertEquals(false, morpion.AddPoint(1, -1));
assertEquals(false, morpion.AddPoint(-1, -1));
assertEquals(false, morpion.AddPoint(3, 3));
assertEquals(false, morpion.AddPoint(3, 0));
assertEquals(false, morpion.AddPoint(0, 4));
}
@Test
void MorpionTestsValeursLimitesPoint() {
Morpion morpion = new Morpion();
assertEquals(false, morpion.AddPoint(Integer.MAX_VALUE, Integer.MAX_VALUE));
assertEquals(false, morpion.AddPoint(Integer.MIN_VALUE, Integer.MIN_VALUE));
assertEquals(false, morpion.AddPoint(Integer.MIN_VALUE, Integer.MAX_VALUE));
assertEquals(false, morpion.AddPoint(Integer.MAX_VALUE, Integer.MIN_VALUE));
}
@Test
@RepeatedTest(value = 100)
void MorpionTestsAleatoiresPoint() {
Morpion morpion = new Morpion();
int x = new Random().nextInt(-5, 5);
int y = new Random().nextInt(-5, 5);
if( x < 3 && y < 3 && x >= 0 && y >= 0) {
assertEquals(true, morpion.AddPoint(x, y));
}
else {
assertEquals(false, morpion.AddPoint(x, y));
}
}
// void MorpionTestsNominauxValidation() {
//
// }
// void MorpionTestsValeursLimitesValidation() {
//
// }
// void MorpionTestsAleatoiresValidation(){
//
// }
}

Binary file not shown.

Binary file not shown.

@ -0,0 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER">
<attributes>
<attribute name="module" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/5"/>
<classpathentry kind="output" path="bin"/>
</classpath>

@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>corr_telecommande_groupe</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
</projectDescription>

@ -0,0 +1,2 @@
eclipse.preferences.version=1
encoding/<project>=UTF-8

@ -0,0 +1,15 @@
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.methodParameters=do not generate
org.eclipse.jdt.core.compiler.codegen.targetPlatform=18
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
org.eclipse.jdt.core.compiler.compliance=18
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
org.eclipse.jdt.core.compiler.debug.localVariable=generate
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=warning
org.eclipse.jdt.core.compiler.release=disabled
org.eclipse.jdt.core.compiler.source=18

@ -0,0 +1,37 @@
// package tetepremiere.commande.groupe;
public class ChargeurTelecommande {
public static void main(String[] args) {
Telecommande remoteControl = new Telecommande();
Lampe lampe = new Lampe("Séjour");
TV tv = new TV("Séjour");
Stereo stereo = new Stereo("Séjour");
Jacuzzi jacuzzi = new Jacuzzi();
CommandeAllumerLampe lampeAllumee = new CommandeAllumerLampe(lampe);
CommandeAllumerStereo stereoAllumee = new CommandeAllumerStereo(stereo);
CommandeAllumerTV tvAllumee = new CommandeAllumerTV(tv);
CommandeAllumerJacuzzi jacuzziAllume = new CommandeAllumerJacuzzi(jacuzzi);
CommandeEteindreLampe lampeEteinte = new CommandeEteindreLampe(lampe);
CommandeEteindreStereo stereoEteinte = new CommandeEteindreStereo(stereo);
CommandeEteindreTV tvEteinte = new CommandeEteindreTV(tv);
CommandeEteindreJacuzzi jacuzziEteint = new CommandeEteindreJacuzzi(jacuzzi);
Commande[] allumageGroupe = { lampeAllumee, stereoAllumee, tvAllumee, jacuzziAllume};
Commande[] extinctionGroupe = { lampeEteinte, stereoEteinte, tvEteinte, jacuzziEteint};
MacroCommande macroAllumageGroupe = new MacroCommande(allumageGroupe);
MacroCommande macroExtinctionGroupe = new MacroCommande(extinctionGroupe);
remoteControl.setCommande(0, macroAllumageGroupe, macroExtinctionGroupe);
System.out.println(remoteControl);
System.out.println("---Exécution de Macro Marche ---");
remoteControl.boutonMarchePresse(0);
System.out.println("--- Exécution de Macro Arret ---");
remoteControl.boutonArretPresse(0);
}
}

@ -0,0 +1,6 @@
// package tetepremiere.commande.groupe;
public interface Commande {
public void executer();
public void annuler();
}

@ -0,0 +1,17 @@
// package tetepremiere.commande.groupe;
public class CommandeAllumerJacuzzi implements Commande {
Jacuzzi jacuzzi;
public CommandeAllumerJacuzzi(Jacuzzi jacuzzi) {
this.jacuzzi = jacuzzi;
}
public void executer() {
jacuzzi.allumer();
jacuzzi.setTemperature(40);
jacuzzi.bouillonner();
}
public void annuler() {
jacuzzi.eteindre();
}
}

@ -0,0 +1,17 @@
// package tetepremiere.commande.groupe;
public class CommandeAllumerLampe implements Commande {
Lampe lampe;
public CommandeAllumerLampe(Lampe lampe) {
this.lampe = lampe;
}
public void executer() {
lampe.marche();
}
public void annuler() {
lampe.arret();
}
}

@ -0,0 +1,15 @@
// package tetepremiere.commande.groupe;
public class CommandeAllumerLampeSejour implements Commande {
Lampe lampe;
public CommandeAllumerLampeSejour(Lampe lampe) {
this.lampe = lampe;
}
public void executer() {
lampe.arret();
}
public void annuler() {
lampe.marche();
}
}

@ -0,0 +1,17 @@
// package tetepremiere.commande.groupe;
public class CommandeAllumerStereo implements Commande {
Stereo stereo;
public CommandeAllumerStereo(Stereo stereo) {
this.stereo = stereo;
}
public void executer() {
stereo.marche();
}
public void annuler() {
stereo.arret();
}
}

@ -0,0 +1,19 @@
// package tetepremiere.commande.groupe;
public class CommandeAllumerStereoAvecCD implements Commande {
Stereo stereo;
public CommandeAllumerStereoAvecCD(Stereo stereo) {
this.stereo = stereo;
}
public void executer() {
stereo.marche();
stereo.setCD();
stereo.setVolume(11);
}
public void annuler() {
stereo.arret();
}
}

Some files were not shown because too many files have changed in this diff Show More

Loading…
Cancel
Save