TP1 jusqu a la partie extension

part1
Fages Tony 1 year ago
parent c8552e117a
commit c9678e6e7a

@ -0,0 +1,5 @@
# Default ignored files
/shelf/
/workspace.xml
# Editor-based HTTP Client requests
/httpRequests/

@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="WEB_MODULE" version="4">
<component name="NewModuleRootManager">
<content url="file://$MODULE_DIR$">
<excludeFolder url="file://$MODULE_DIR$/.tmp" />
<excludeFolder url="file://$MODULE_DIR$/temp" />
<excludeFolder url="file://$MODULE_DIR$/tmp" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/.idea/JokesApp.iml" filepath="$PROJECT_DIR$/.idea/JokesApp.iml" />
</modules>
</component>
</project>

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="$PROJECT_DIR$/.." vcs="Git" />
</component>
</project>

@ -0,0 +1,7 @@
export function loadExtensions() {
if (!string.prototype.toNounours) {
string.prototype.toNounours = function () {
return new Nounours(this)
};
}
}

@ -0,0 +1,15 @@
class CustomJoke extends Joke{
get id(): string {
return this._id;
}
constructor(type : string, setup : string,punchline : string,image : string ,id : string) {
super(type,setup,punchline,image);
this._id = id
}
private _id : string
}

@ -0,0 +1,4 @@
class CustomStub{
public Customjoke = '[{type:"type",setup:"setup",image:"image",punchline:"punchline",id:"id"}]'
}

@ -0,0 +1,38 @@
abstract class Joke{
private _type : string
private _setup : string
private _punchline : string
private _image : string
protected constructor(type : string, setup : string, punchline : string, image : string ) {
this._type = type
this._setup = setup
this._punchline = punchline
this._image = image
}
public type(): string {
return this._type;
}
public get setup(): string {
return this._setup;
}
public get punchline(): string {
return this._punchline;
}
public get image(): string {
return this._image;
}
public summary():string{
return this.setup.padEnd(25,'.')
}
public description():string{
return this.type+ ' - ' +this.summary()
}
}

@ -0,0 +1,25 @@
class JokeFactory {
public static createCustomJokes(jsonArray: string) : CustomJoke[]{
let array = []
let json = JSON.parse(jsonArray)
json.forEach(function (joke) {
array.push(new CustomJoke(joke.type,joke.setup,joke.punchline,joke.image,joke.id))
})
return array
}
public 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))
})
return array
}
}

@ -0,0 +1,18 @@
class SampleJoke extends Joke{
private _id : number
constructor(type : string, setup : string,punchline : string,image : string ,id : number) {
super(type,setup,punchline,image);
this._id = id
}
get id(): number {
return this._id;
}
set id(value: number) {
this._id = value;
}
}

@ -0,0 +1,3 @@
class SampleStub{
public Customjoke = '[{type:"typeSample",setup:"setupSample",image:"imageSample",punchline:"punchlineSample",id:"idSample"}]'
}

@ -8,10 +8,12 @@
"name": "jokesapp",
"version": "1.0.0",
"dependencies": {
"@types/react": "~18.2.45",
"expo": "~50.0.3",
"expo-status-bar": "~1.11.1",
"react": "18.2.0",
"react-native": "0.73.2"
"react-native": "0.73.2",
"typescript": "^5.3.0"
},
"devDependencies": {
"@babel/core": "^7.20.0"
@ -5991,6 +5993,26 @@
"undici-types": "~5.26.4"
}
},
"node_modules/@types/prop-types": {
"version": "15.7.11",
"resolved": "https://registry.npmjs.org/@types/prop-types/-/prop-types-15.7.11.tgz",
"integrity": "sha512-ga8y9v9uyeiLdpKddhxYQkxNDrfvuPrlFb0N1qnZZByvcElJaXthF1UhvCh9TLWJBEHeNtdnbysW7Y6Uq8CVng=="
},
"node_modules/@types/react": {
"version": "18.2.48",
"resolved": "https://registry.npmjs.org/@types/react/-/react-18.2.48.tgz",
"integrity": "sha512-qboRCl6Ie70DQQG9hhNREz81jqC1cs9EVNcjQ1AU+jH6NFfSAhVVbrrY/+nSF+Bsk4AOwm9Qa61InvMCyV+H3w==",
"dependencies": {
"@types/prop-types": "*",
"@types/scheduler": "*",
"csstype": "^3.0.2"
}
},
"node_modules/@types/scheduler": {
"version": "0.16.8",
"resolved": "https://registry.npmjs.org/@types/scheduler/-/scheduler-0.16.8.tgz",
"integrity": "sha512-WZLiwShhwLRmeV6zH+GkbOFT6Z6VklCItrDioxUnv+u4Ll+8vKeFySoFyK/0ctcRpOmwAicELfmys1sDc/Rw+A=="
},
"node_modules/@types/stack-utils": {
"version": "2.0.3",
"resolved": "https://registry.npmjs.org/@types/stack-utils/-/stack-utils-2.0.3.tgz",
@ -7106,6 +7128,11 @@
"node": ">=8"
}
},
"node_modules/csstype": {
"version": "3.1.3",
"resolved": "https://registry.npmjs.org/csstype/-/csstype-3.1.3.tgz",
"integrity": "sha512-M1uQkMl8rQK/szD0LNhtqxIPLpimGm8sOBwU7lLnCpSbTyY3yeU1Vc7l4KT5zT4s/yOxHH5O7tIuuLOCnLADRw=="
},
"node_modules/dag-map": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/dag-map/-/dag-map-1.0.2.tgz",
@ -12394,6 +12421,18 @@
"url": "https://github.com/sponsors/sindresorhus"
}
},
"node_modules/typescript": {
"version": "5.3.3",
"resolved": "https://registry.npmjs.org/typescript/-/typescript-5.3.3.tgz",
"integrity": "sha512-pXWcraxM0uxAS+tN0AG/BF2TyqmHO014Z070UsJ+pFvYuRSq8KH8DmWpnbXe0pEPDHXZV3FcAbJkijJ5oNEnWw==",
"bin": {
"tsc": "bin/tsc",
"tsserver": "bin/tsserver"
},
"engines": {
"node": ">=14.17"
}
},
"node_modules/ua-parser-js": {
"version": "1.0.37",
"resolved": "https://registry.npmjs.org/ua-parser-js/-/ua-parser-js-1.0.37.tgz",

@ -12,7 +12,9 @@
"expo": "~50.0.3",
"expo-status-bar": "~1.11.1",
"react": "18.2.0",
"react-native": "0.73.2"
"react-native": "0.73.2",
"typescript": "^5.3.0",
"@types/react": "~18.2.45"
},
"devDependencies": {
"@babel/core": "^7.20.0"

@ -0,0 +1,9 @@
{
"compilerOptions": {
"typeRoots": [
"./node_modules/@types",
"./types"
]
},
"extends": "expo/tsconfig.base"
}
Loading…
Cancel
Save