0
0
Fork 0

Implement toJSON and fromJSON methods.

This commit is contained in:
Oliver-Akins 2021-01-06 16:24:52 -07:00
parent b49662f00f
commit 2e8497c77d

View file

@ -69,4 +69,28 @@ export class Team {
}; };
this._answers[answerIndex - 1] = answer; this._answers[answerIndex - 1] = answer;
}; };
public toJSON(): datastoreTeam {
/**
* Converts the given object into a JSON representation of the data
*/
return {
questions: this._questions,
answers: this._answers,
hand: this._hand,
id: this.id,
};
};
public static fromJSON(data: datastoreTeam): Team {
/**
* Converts a team JSON object back into a Team object.
*/
let t = new Team(data.id);
t._questions = data.questions;
t._answers = data.answers;
t._hand = data.hand;
return t;
};
}; };