일기장 오늘의 App.ts
- 리눅스
- 56
- 6
- 4
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());
}
}
분류 | 제목 | 글쓴이 | 날짜 | 조회 수 | |
---|---|---|---|---|---|
공지 | [공지] 츄르내역_240102 19 | 조유리 | 3076 | 12 | |
공지 | [공지] 공지사항_220412 30 | 조유리 | 6539 | 64 | |
뒤진갤입니다 |
기본
|
Kaka | 256 | 9 | |
뒤진갤입니다 |
기본
|
갓천갓프시 | 134 | 3 | |
뒤진갤입니다 |
이미지
|
시나모롤 | 113 | 4 | |
연재 |
기본
|
미사와미츠하루 | 94 | 8 | |
뒤진갤입니다 |
이미지
|
적창 | 66 | 4 | |
뒤진갤입니다 |
이미지
|
담대 | 64 | 4 | |
뒤진갤입니다 |
기본
|
이서연 | 83 | 4 | |
뒤진갤입니다 |
기본
|
슈화 | 116 | 6 | |
뒤진갤입니다 |
이미지
|
♥무케♥ | 108 | 8 | |
뒤진갤입니다 |
기본
|
♥무케♥ | 71 | 4 | |
뒤진갤입니다 |
기본
|
TrueRomance | 85 | 3 | |
뒤진갤입니다 |
기본
|
이서연 | 81 | 3 | |
뒤진갤입니다 |
기본
|
단군할아버지 | 80 | 1 | |
뒤진갤입니다 |
기본
|
정은비 | 68 | 4 | |
뒤진갤입니다 |
기본
|
블랙워그레이몬 | 85 | 5 | |
뒤진갤입니다 |
이미지
|
시나모롤 | 149 | 12 | |
뒤진갤입니다 |
기본
|
단군할아버지 | 92 | 4 | |
뒤진갤입니다 |
기본
|
♥무케♥ | 76 | 4 | |
뒤진갤입니다 |
파일
|
Sso! | 102 | 6 | |
뒤진갤입니다 |
이미지
|
슈화 | 67 | 2 |