1
0

input_assessment.js 702 B

12345678910111213141516171819202122232425262728
  1. import { Input } from './../io/input';
  2. import { LocalizedStrings } from '../services/localizedStringsService';
  3. export class InputAssessment extends Input {
  4. constructor (input_list) {
  5. super();
  6. this.index = 0;
  7. this.input_list = input_list.map((val) => {
  8. return {"value": val, "read": false};
  9. });
  10. }
  11. requestInput (callback) {
  12. if(this.index < this.input_list.length) {
  13. const input = this.input_list[this.index];
  14. input.read = true;
  15. this.index += 1;
  16. callback(input.value);
  17. } else {
  18. throw new Error(LocalizedStrings.getError("exceeded_input_request"));
  19. }
  20. }
  21. isInputAvailable () {
  22. return this.index < this.input_list.length;
  23. }
  24. }