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"}]'
|
||||
}
|
@ -0,0 +1,9 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"typeRoots": [
|
||||
"./node_modules/@types",
|
||||
"./types"
|
||||
]
|
||||
},
|
||||
"extends": "expo/tsconfig.base"
|
||||
}
|
Loading…
Reference in new issue