diff --git a/.expo/README.md b/.expo/README.md
new file mode 100644
index 0000000..fd146b4
--- /dev/null
+++ b/.expo/README.md
@@ -0,0 +1,15 @@
+> Why do I have a folder named ".expo" in my project?
+
+The ".expo" folder is created when an Expo project is started using "expo start" command.
+
+> What do the files contain?
+
+- "devices.json": contains information about devices that have recently opened this project. This is used to populate the "Development sessions" list in your development builds.
+- "packager-info.json": contains port numbers and process PIDs that are used to serve the application to the mobile device/simulator.
+- "settings.json": contains the server configuration that is used to serve the application manifest.
+
+> Should I commit the ".expo" folder?
+
+No, you should not share the ".expo" folder. It does not contain any information that is relevant for other developers working on the project, it is specific to your machine.
+
+Upon project creation, the ".expo" folder is already added to your ".gitignore" file.
diff --git a/.expo/settings.json b/.expo/settings.json
new file mode 100644
index 0000000..92bc513
--- /dev/null
+++ b/.expo/settings.json
@@ -0,0 +1,8 @@
+{
+ "hostType": "lan",
+ "lanType": "ip",
+ "dev": true,
+ "minify": false,
+ "urlRandomness": null,
+ "https": false
+}
diff --git a/JokesApp/.idea/misc.xml b/JokesApp/.idea/misc.xml
new file mode 100644
index 0000000..3668dc8
--- /dev/null
+++ b/JokesApp/.idea/misc.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/JokesApp/App.js b/JokesApp/App.js
deleted file mode 100644
index 09f879b..0000000
--- a/JokesApp/App.js
+++ /dev/null
@@ -1,20 +0,0 @@
-import { StatusBar } from 'expo-status-bar';
-import { StyleSheet, Text, View } from 'react-native';
-
-export default function App() {
- return (
-
- Open up App.js to start working on your app!
-
-
- );
-}
-
-const styles = StyleSheet.create({
- container: {
- flex: 1,
- backgroundColor: '#fff',
- alignItems: 'center',
- justifyContent: 'center',
- },
-});
diff --git a/JokesApp/App.tsx b/JokesApp/App.tsx
new file mode 100644
index 0000000..0c72332
--- /dev/null
+++ b/JokesApp/App.tsx
@@ -0,0 +1,33 @@
+import {StatusBar} from 'expo-status-bar';
+import {StyleSheet, Text, View} from 'react-native';
+import {JokeStub} from "./model/JokeStub";
+import {JokeFactory} from "./model/JokeFactory";
+import {loadExtensions} from "./extensions";
+loadExtensions();
+
+export default function App() {
+ let customJokes = JokeFactory.createCustomJokes(JokeStub.customJokes);
+ let samplesJokes = JokeFactory.createSampleJokes(JokeStub.sampleJokes);
+
+ return (
+
+ CustomJokes
+ {customJokes.displayJoke()}
+ SamplesJokes
+ {samplesJokes.displayJoke()}
+
+
+
+ );
+}
+
+// Styles pour le composant
+const styles = StyleSheet.create({
+ container: {
+ flex: 1,
+ backgroundColor: '#fff',
+ alignItems: 'center',
+ justifyContent: 'center',
+ },
+});
+
diff --git a/JokesApp/extension.js b/JokesApp/extension.js
deleted file mode 100644
index e2e7cf0..0000000
--- a/JokesApp/extension.js
+++ /dev/null
@@ -1,7 +0,0 @@
-export function loadExtensions() {
- if (!string.prototype.toNounours) {
- string.prototype.toNounours = function () {
- return new Nounours(this)
- };
- }
-}
\ No newline at end of file
diff --git a/JokesApp/extensions.js b/JokesApp/extensions.js
new file mode 100644
index 0000000..a15cef2
--- /dev/null
+++ b/JokesApp/extensions.js
@@ -0,0 +1,9 @@
+// Fonction pour étendre le prototype d'Array avec une nouvelle méthode print
+export function loadExtensions() {
+ // Ajout de la méthode print au prototype d'Array
+ if (!Array.prototype.displayJoke) {
+ Array.prototype.displayJoke = function () {
+ return this.map((item) => item.description() + '\n')
+ };
+ }
+}
diff --git a/JokesApp/model/CustomJoke.ts b/JokesApp/model/CustomJoke.ts
index 004637c..572a9d8 100644
--- a/JokesApp/model/CustomJoke.ts
+++ b/JokesApp/model/CustomJoke.ts
@@ -1,4 +1,8 @@
-class CustomJoke extends Joke{
+import { Joke } from "./Joke";
+
+export class CustomJoke extends Joke{
+ private _id : string
+
get id(): string {
return this._id;
}
@@ -9,7 +13,6 @@ class CustomJoke extends Joke{
}
- private _id : string
}
\ No newline at end of file
diff --git a/JokesApp/model/CustomStub.ts b/JokesApp/model/CustomStub.ts
deleted file mode 100644
index 78ea955..0000000
--- a/JokesApp/model/CustomStub.ts
+++ /dev/null
@@ -1,4 +0,0 @@
-class CustomStub{
- public Customjoke = '[{type:"type",setup:"setup",image:"image",punchline:"punchline",id:"id"}]'
-}
-
diff --git a/JokesApp/model/Joke.ts b/JokesApp/model/Joke.ts
index fdc51a6..effdb06 100644
--- a/JokesApp/model/Joke.ts
+++ b/JokesApp/model/Joke.ts
@@ -1,4 +1,4 @@
-abstract class Joke{
+export abstract class Joke{
private _type : string
private _setup : string
@@ -28,11 +28,13 @@ abstract class Joke{
}
public summary():string{
- return this.setup.padEnd(25,'.')
+ return this.setup.substring(0,25) + ' ...'
}
public description():string{
- return this.type+ ' - ' +this.summary()
+ return this.type() + ' - ' +this.summary()
}
+
+
}
diff --git a/JokesApp/model/JokeFactory.ts b/JokesApp/model/JokeFactory.ts
index 43c9f1f..7097a8b 100644
--- a/JokesApp/model/JokeFactory.ts
+++ b/JokesApp/model/JokeFactory.ts
@@ -1,4 +1,7 @@
-class JokeFactory {
+import { CustomJoke } from "./CustomJoke";
+import { SampleJoke } from "./SampleJoke";
+
+export class JokeFactory {
public static createCustomJokes(jsonArray: string) : CustomJoke[]{
let array = []
@@ -7,18 +10,18 @@ class JokeFactory {
array.push(new CustomJoke(joke.type,joke.setup,joke.punchline,joke.image,joke.id))
})
- return array
+ return array;
}
- public static createSampleJokes(jsonArray: string) : SampleJoke[] {
- let array = []
- let json = JSON.parse(jsonArray)
+ static createSampleJokes(jsonArray: string): SampleJoke[] {
+ let array = [];
+ let json = JSON.parse(jsonArray);
json.forEach(function (joke) {
- array.push(new SampleJoke(joke.type,joke.setup,joke.punchline,joke.image,joke.id))
+ array.push(new SampleJoke(joke.type, joke.setup, joke.punchline, joke.image, joke.id));
})
- return array
+ return array;
}
diff --git a/JokesApp/model/JokeStub.ts b/JokesApp/model/JokeStub.ts
index e69de29..c3db33f 100644
--- a/JokesApp/model/JokeStub.ts
+++ b/JokesApp/model/JokeStub.ts
@@ -0,0 +1,10 @@
+import {SampleJoke} from "./SampleJoke";
+
+export class JokeStub {
+ // Données JSON pour les CustomJokes
+ public static customJokes = '[{"type":"custom", "setup":"Quel jour les poules ont-elles l anus dilaté au maximum ?", "punchline":"Le jour où elles passent du coq à l âne.", "image":"image1", "id":"id1"}, {"type":"custom", "setup":"Savez-vous comment on appelle le sexe de Michael Jackson ???", "punchline":"Vérité ! Car la vérité sort toujours de la bouche des enfants .", "image":"image2", "id":"id2"}]';
+
+ // Données JSON pour les SampleJokes
+ public static sampleJokes = '[{"type":"sample", "setup":"Que dit un escargot quand il croise une limace ?", "punchline":"Oh la belle décapotable ", "image":"image1", "id":"id1"}, {"type":"sample", "setup":"Qu est ce qui n est pas un steak ?", "punchline":"Une pastèque.", "image":"image2", "id":"id2"}]';
+}
+
diff --git a/JokesApp/model/SampleJoke.ts b/JokesApp/model/SampleJoke.ts
index e5f7ecb..e8270de 100644
--- a/JokesApp/model/SampleJoke.ts
+++ b/JokesApp/model/SampleJoke.ts
@@ -1,6 +1,8 @@
-class SampleJoke extends Joke{
+import { Joke } from "./Joke";
- private _id : number
+export class SampleJoke extends Joke{
+
+ private _id : number
constructor(type : string, setup : string,punchline : string,image : string ,id : number) {
super(type,setup,punchline,image);
@@ -11,8 +13,4 @@ class SampleJoke extends Joke{
return this._id;
}
- set id(value: number) {
- this._id = value;
- }
-
}
\ No newline at end of file
diff --git a/JokesApp/model/SampleStub.ts b/JokesApp/model/SampleStub.ts
deleted file mode 100644
index 0de5f60..0000000
--- a/JokesApp/model/SampleStub.ts
+++ /dev/null
@@ -1,3 +0,0 @@
-class SampleStub{
- public Customjoke = '[{type:"typeSample",setup:"setupSample",image:"imageSample",punchline:"punchlineSample",id:"idSample"}]'
-}
\ No newline at end of file
diff --git a/JokesApp/types/types.ts b/JokesApp/types/types.ts
new file mode 100644
index 0000000..efc3c34
--- /dev/null
+++ b/JokesApp/types/types.ts
@@ -0,0 +1,8 @@
+export {}
+
+// Extension de l'interface globale Array avec une nouvelle méthode print
+declare global {
+ interface Array {
+ displayJoke(): string[];
+ }
+}