You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Tp_ReactNative/JokesApp/model/JokeFactory.ts

28 lines
738 B

import { CustomJoke } from "./CustomJoke";
import { SampleJoke } from "./SampleJoke";
export 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;
}
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;
}
}