/*
[ λ¬Έμ μκ° ]
λ€μ μꡬμ¬νμ λ§μ‘±νλ Pokemon ν΄λμ€λ₯Ό μμ±νμΈμ
- λ€μ 3κ°μ νλλ₯Ό κ°μ΅λλ€.
1. name νλλ String νμ
μ΄λ©° Publicμ
λλ€.
2. skill νλλ String νμ
μ΄λ©° Public μ
λλ€.
3. type νλλ String νμ
μ΄λ©° ReadOnly(μ½κΈ° μ μ©)νλ μ
λλ€.
- λ€μ 2κ°μ λ©μλλ₯Ό κ°μ΅λλ€.
1. getName λ©μλλ name νλμ κ°μ λ°νν©λλ€.
2. setSkill λ©μλλ String νμ
μ 맀κ°λ³μλ₯Ό λ°μ skill νλμ κ°μ μ
λ°μ΄νΈ ν©λλ€.
*/
/* [Quiz] ꡬν μκ·Έλμ³λ₯Ό μμ±νμΈμ */
class Pokemon {}
/* [Test] μ¬κΈ°λΆν°λ μ λ΅μ 체ν¬νκΈ° μν μ©λλ‘ μμ νμ§ μμ΅λλ€ */
const pikachu = new Pokemon("νΌμΉ΄μΈ", "λ°±λ§λ³ΌνΈ", "μ κΈ°");
pikachu.getName();
pikachu.setSkill("μ²λ§λ³ΌνΈ!");
class Pokemon {
name: string;
skill:string;
readonly type:string;
constructor(name:string, skill:string, type:string){
this.name=name;
this.skill=skill;
this.type=type;
}
getName():string{
return this.name;
}
setSkill(skill:string):string{
return `${this.skill}` //β
}
}
class Pokemon {
constructor(public name: string, public skill: string, readonly type: string) {}
getName(): string {
return this.name;
}
setSkill(skill: string): void {
this.skill = skill;
}
}