pour waim

This commit is contained in:
didier amyot committed 2023-12-22 20:40:56 -05:00
1 parent f792f15caa
commit 0dd3b65a74
2 files changed
+216 -13

No files matched your search

+183 -10
View File
@@ -10,23 +10,60 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 33,
"id": "a72f5733-4c3f-4a81-95a7-4ff0f486c292",
"metadata": {},
"outputs": [],
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"[ \u001b[32m\"a\"\u001b[39m, \u001b[32m\"b\"\u001b[39m, \u001b[32m\"e\"\u001b[39m, \u001b[32m\"f\"\u001b[39m, \u001b[32m\"c\"\u001b[39m ]\n",
"[ \u001b[32m\"d\"\u001b[39m ]\n"
]
}
],
"source": [
"\n",
"// partie de dodgeball\n",
"\n",
"class DodgeballGame{\n",
"\n",
" constructor(joueurs) {\n",
" this.joueursEnVie = joueurs;\n",
" this.joueursMorts = [];\n",
" \n",
" }\n",
"\n",
" kill(joueur){\n",
" this.joueursMorts.push(joueur);\n",
" const nouveauJoueursEnVie = []\n",
" for(const joueurEnVie of this.joueursEnVie){\n",
" if(this.joueursMorts.indexOf(joueurEnVie) === -1){\n",
" nouveauJoueursEnVie.push(joueurEnVie);\n",
" }\n",
" }\n",
" this.joueursEnVie = nouveauJoueursEnVie;\n",
" }\n",
"\n",
" catchBall(){\n",
" if(this.joueursMorts.length < 1){\n",
" return;\n",
" }\n",
" const jesus = this.joueursMorts.shift();\n",
" this.joueursEnVie.push(jesus);\n",
" }\n",
" \n",
"}\n",
"\n",
"let players = [\"a\", \"b\", \"c\", \"d\", \"e\", \"f\"];\n",
"\n",
"function listeDeJoueurMorts(){}\n",
"\n",
"function listDeJoueur(){}\n",
"\n",
"function kill(nomDuJoueur){}\n",
"\n",
"function attrape(){}"
"let game = new DodgeballGame([\"a\", \"b\", \"c\", \"d\", \"e\", \"f\"]);\n",
"game.kill(\"c\");\n",
"game.kill(\"d\")\n",
"game.catchBall();\n",
"console.log(game.joueursEnVie);\n",
"console.log(game.joueursMorts);\n"
]
},
{
@@ -219,10 +256,146 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 8,
"id": "8f64482f-2d87-4f0a-b579-050c0bbe477a",
"metadata": {},
"outputs": [],
"source": [
"import {Point} from \"https://cdn.jsdelivr.net/gh/didiercrunch/cours-420-301-ah@tp1.1/modules-examples/mod.js\""
]
},
{
"cell_type": "code",
"execution_count": 10,
"id": "00102d6b-2997-4fdb-a55f-ed812e1dade1",
"metadata": {},
"outputs": [],
"source": [
"let point = new Point(34, 78)"
]
},
{
"cell_type": "code",
"execution_count": 11,
"id": "9f79bbee-234f-4bd2-9689-77896c847bdd",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"\u001b[33m34\u001b[39m"
]
},
"execution_count": 11,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"point.getX()"
]
},
{
"cell_type": "code",
"execution_count": 12,
"id": "9ed8a8a9-303b-4e0b-bdb2-e69b2ea302f6",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"\u001b[33m78\u001b[39m"
]
},
"execution_count": 12,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"point.getY()"
]
},
{
"cell_type": "code",
"execution_count": 13,
"id": "a3ff4415-66bf-4b30-858f-90da7b352669",
"metadata": {},
"outputs": [],
"source": [
"class Point2D{\n",
" constructor(x, y){\n",
" this.x = x;\n",
" this.y = y;\n",
" }\n",
"\n",
" distanceFromOrigin(){\n",
" return Math.sqrt(this.x * this.x + this.y * this.y);\n",
" }\n",
"}"
]
},
{
"cell_type": "code",
"execution_count": 15,
"id": "19d175c5-8abd-44d0-8611-33cc543ef608",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"\u001b[33m85.0881895447306\u001b[39m"
]
},
"execution_count": 15,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"let point2D = new Point2D(34, 78)\n",
"point2D.distanceFromOrigin()"
]
},
{
"cell_type": "code",
"execution_count": 17,
"id": "92669a40-4cea-49a2-b826-1bed8712324a",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"URL {\n",
" href: \u001b[32m\"https://example.com/didier/rocks\"\u001b[39m,\n",
" origin: \u001b[32m\"https://example.com\"\u001b[39m,\n",
" protocol: \u001b[32m\"https:\"\u001b[39m,\n",
" username: \u001b[32m\"\"\u001b[39m,\n",
" password: \u001b[32m\"\"\u001b[39m,\n",
" host: \u001b[32m\"example.com\"\u001b[39m,\n",
" hostname: \u001b[32m\"example.com\"\u001b[39m,\n",
" port: \u001b[32m\"\"\u001b[39m,\n",
" pathname: \u001b[32m\"/didier/rocks\"\u001b[39m,\n",
" hash: \u001b[32m\"\"\u001b[39m,\n",
" search: \u001b[32m\"\"\u001b[39m\n",
"}"
]
},
"execution_count": 17,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"new URL(\"https://example.com/didier/rocks\")"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "e893b86f-148e-444b-b3dd-503a008c366b",
"metadata": {},
"outputs": [],
"source": []
}
],