import {Injectable} from '@angular/core';

@Injectable({
  providedIn: 'root'
})
export class RunCodeService {

  status = 'Compiling...';
  result = 0;

  constructor() {
  }

  run(): void {
    const output = `25
abcd
150`;
    const statusArray = ['Uploading...', 'Compiling...', 'Running...', `Done!

        <div class="code">${output}</div>`];

    this.result = 0;
    let time = 0;
    for (const status of statusArray) {
      setTimeout(() => {
        this.status = status;
      }, time);
      time += 2000;
    }

    setTimeout(() => {
      this.result = 1;
    }, 6000);
  }
}
