• A
    • T
    • C
  • 해외축구 축구잡담
  • [해축백일장] FiveBigLeagues.ts

    • 무명의덕
    • 2023.07.07 - 22:12 2023.07.07 - 21:56  109

class Team {

public name: string;

public city: string;

public point: number;

public manager: string;

public players: string[];

public tactics: 'normal' | 'experimental';

 

constructor(name: string, city: string) {

this.name = name;

this.city = city;

this.point = 0;

this.manager = '';

this.players = [];

this.tactics = 'normal';

}

}

 

abstract class League {

public fixture: Team[];

public numberOfTeams: number;

 

constructor(teamList: Team[]) {

this.fixture = teamList;

this.numberOfTeams = teamList.length;

}

 

protected rank() {

this.fixture.sort((a, b) => b.point - a.point);

}

 

public match(homeTeam: Team, awayTeam: Team) {

const result = Math.floor(Math.random() * 3);

 

if (result == 0) {

homeTeam.point += 3;

} else if (result == 1) {

awayTeam.point += 3;

} else {

homeTeam.point += 1;

awayTeam.point += 1;

}

 

this.rank();

}

 

abstract finalRound(): void;

}

 

class PremierLeague extends League {

finalRound() {

if (this.fixture[0].manager == 'Pep Guardiola' && this.fixture[0].tactics != 'experimental')

console.log('Treble!');

}

}

 

class LaLiga extends League {

finalRound() {

if ((this.fixture[0].name == 'Real Madrid' || 'Barcelona')

|| (this.fixture[0].name == 'Atletico Madrid' && this.fixture[0].tactics == 'experimental')) {

console.log(`${this.fixture[0].name} is the Champion!`);

} else throw Error('Not LaLiga!');

}

}

 

class SerieA extends League {

finalRound() {

const minjae = this.fixture[0].players.findIndex(player => player == 'Minjae Kim')

if (minjae != -1) this.fixture[0].players.splice(minjae, 1);

}

}

 

class Bundesliga extends League {

finalRound() {

if (this.fixture[0].name != 'Bayern Munich') {

console.log('Assist by Jaesung Lee!');

this.fixture[0].point -= 2;

this.rank();

}

}

}

 

class LigueUn extends League {

finalRound() {

if (this.fixture[0].manager == 'Christophe Galtier') {

console.log('Arrested!');

this.fixture[0].manager = 'Luis Enrique';

}

}

}

이 게시물을..
  • 소쇼가 강등 피하려고 선수 다 파는구나무명의덕
  • 개집 라이스 오긴하냐?무명의덕
댓글 쓰기 에디터 사용하기 닫기
  • 목록 목록
  • 소쇼가 강등 피하려고 선수 다 파는구나
  • 개집 라이스 오긴하냐?
  • 목록