일기장 오늘의 App.ts

import { Component, createElement } from 'react';

import { Text } from 'react-native';

 

class Volleyball {

  protected set_score = new Array<number>(2);

  protected first_set = new Array<number>(2);

  protected second_set = new Array<number>(2);

  protected third_set = new Array<number>(2);

  protected fourth_set = new Array<number>(2);

  protected deciding_set = new Array<number>(2);

  protected scoreboard = new Array(

    this.set_score,

    this.first_set,

    this.second_set,

    this.third_set,

    this.fourth_set,

    this.deciding_set

  );

 

  protected point() {

    let p = Math.floor(Math.random() * 2);

    return p;

  }

 

  protected print(j: number) {

    let i = 0,

      str = '\t',

      set_score = 'SET SCORE',

      home = 'HOME',

      away = 'AWAY';

 

    for (i = 0; i <= j; ++i) {

      if (i > 0) set_score += `\t${i} SET`;

      home += '\t' + this.scoreboard[i][0];

      away += '\t' + this.scoreboard[i][1];

    }

 

    str += set_score + '\n' + home + '\n' + away;

    return str;

  }

 

  protected init() {

    let j = 0;

 

    for (j = 0; j < 6; ++j) {

      this.scoreboard[j][0] = 0;

      this.scoreboard[j][1] = 0;

    }

  }

 

  public game() {

    let j = 1,

      p = 0;

 

    this.init();

 

    while (j < 4) {

      while (this.scoreboard[j][0] < 25 && this.scoreboard[j][1] < 25) {

        p = this.point();

        ++this.scoreboard[j][p];

      }

 

      if (this.scoreboard[j][0] === 24 || this.scoreboard[j][1] === 24)

        while (

          this.scoreboard[j][0] - this.scoreboard[j][1] === 1 ||

          this.scoreboard[j][0] === this.scoreboard[j][1] ||

          this.scoreboard[j][1] - this.scoreboard[j][0] === 1

        ) {

          p = this.point();

          ++this.scoreboard[j][p];

        }

 

      if (this.scoreboard[j][0] > this.scoreboard[j][1])

        ++this.scoreboard[0][0];

      else ++this.scoreboard[0][1];

 

      if (this.scoreboard[0][0] < 3 && this.scoreboard[0][1] < 3) ++j;

      else break;

    }

 

    if (this.scoreboard[0][0] < 3 && this.scoreboard[0][1] < 3) {

      while (this.scoreboard[j][0] < 25 && this.scoreboard[j][1] < 25) {

        p = this.point();

        ++this.scoreboard[j][p];

      }

 

      if (this.scoreboard[j][0] === 24 || this.scoreboard[j][1] === 24)

        while (

          this.scoreboard[j][0] - this.scoreboard[j][1] === 1 ||

          this.scoreboard[j][0] === this.scoreboard[j][1] ||

          this.scoreboard[j][1] - this.scoreboard[j][0] === 1

        ) {

          p = this.point();

          ++this.scoreboard[j][p];

        }

 

      if (this.scoreboard[j][0] > this.scoreboard[j][1])

        ++this.scoreboard[0][0];

      else ++this.scoreboard[0][1];

 

      if (this.scoreboard[0][0] < 3 && this.scoreboard[0][1] < 3) ++j;

    }

 

    if (this.scoreboard[0][0] < 3 && this.scoreboard[0][1] < 3) {

      while (this.scoreboard[j][0] < 15 && this.scoreboard[j][1] < 15) {

        p = this.point();

        ++this.scoreboard[j][p];

      }

 

      if (this.scoreboard[j][0] === 14 || this.scoreboard[j][1] === 14)

        while (

          this.scoreboard[j][0] - this.scoreboard[j][1] === 1 ||

          this.scoreboard[j][0] === this.scoreboard[j][1] ||

          this.scoreboard[j][1] - this.scoreboard[j][0] === 1

        ) {

          p = this.point();

          ++this.scoreboard[j][p];

        }

 

      if (this.scoreboard[j][0] > this.scoreboard[j][1])

        ++this.scoreboard[0][0];

      else ++this.scoreboard[0][1];

    }

 

    return this.print(j);

  }

}

 

export default class App extends Component {

  protected match = new Volleyball();

 

  render() {

    return createElement(Text, undefined, this.match.game());

  }

}

댓글 6

luve 2022.04.12. 15:38
이 어지러운 글씨체는 머꼬
댓글
리눅스 작성자 2022.04.12. 15:40
 luve
그래서 코딩용 글꼴로 수정함
댓글
리눅스 작성자 2022.04.12. 16:39
 대한민국
홉스 루소 로크
이런것보단 낫잖어
댓글
대한민국 2022.04.12. 16:41
 리눅스
구와아아아아악 윤리와 사상 가져다 치워주셈
댓글
리눅스 작성자 2022.04.12. 16:45
 대한민국
사상? ㅈㄱㄹ
댓글
권한이 없습니다. 로그인

신고

"님의 댓글"

이 댓글을 신고 하시겠습니까?

삭제

"님의 댓글"

이 댓글을 삭제하시겠습니까?

분류 제목 글쓴이 날짜 조회 수
공지 [공지] 츄르내역_240102 19 조유리 3076 12
공지 [공지] 공지사항_220412 30 조유리 6539 64
일기장
이미지
Sso! 31 1
일기장
기본
메르시장인 51 7
일기장
기본
메르시장인 60 7
일기장
기본
메르시장인 82 14
일기장
기본
메르시장인 59 9
일기장
기본
메르시장인 55 5
일기장
기본
메르시장인 41 5
일기장
기본
메르시장인 44 8
일기장
기본
메르시장인 69 11
일기장
기본
메르시장인 64 8
일기장
기본
철이두개면두철 28 3
일기장
기본
메르시장인 46 8
일기장
이미지
♥무케♥ 35 3
일기장
이미지
구내염에는알보칠 158 5
일기장
기본
메르시장인 63 9
일기장
기본
메르시장인 58 8
일기장
이미지
정진솔 31 3
일기장
이미지
정진솔 64 7
일기장
기본
육상천재방예나 62 5
일기장
기본
메르시장인 80 10