Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create PR #25

Open
wants to merge 5 commits into
base: Novoselov_Nikolaj_Vitalevich
Choose a base branch
from

Conversation

GitSwaggCat
Copy link

No description provided.

DIED = "Died"
}
export class Mouse {
_heathpool: number = 100;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

проверим настройки линтера

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

а _heathpool не должен быть приватным или protected

@@ -0,0 +1,42 @@
export enum Mode{
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

enum можно вынести в отдельный файл

this._heathpool-=10
if (this._heathpool > 0) {
return `Вы ударили мышь, теперь у неё ${this._heathpool} здоровья`
}else{
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

не используйте else

return `Вы ударили мышь, теперь у неё ${this._heathpool} здоровья`
}else{
this._mode = Mode.DIED
return "Мышь сдохла"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

линтер точно не заработал - нужна ; в конце строки

_healthpool: number = 100;
private _age: number;
_color: string;
_mode: Mode = Mode.ALIVE;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

и извне могу ее убить - поле то публичное

this._color = color;
};
set year(year: number) {
this._age = year > 0 && year < 4 ? year : 0
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

при неправильном значении бросайте exception

constructor(color: string) {
this._color = color;
};
sound(): string {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

тогда сделайте его абстрактным

export class Animal {
_mode: Mode = Mode.ALIVE;
_color: string;
_healthpool: number = 100;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

и вот это поле публичное

}

sound(): string {
return `Фыр-фыр`;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

Comment on lines +9 to +11
set year(year: number) {
this._age = year > 0 && year < 20 ? year : 0;
};
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

а вот тут интересно - у вас у всех есть возраст - но нет в базовом классе -> я могу создать животьное у которого не будет этого года - что может привести к неожиданному поведению

this.year = year;
};
set year(year: number) {
this._age = year > 0 && year < 25 ? year : 0;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

при неправильном годе - бросайте exception

кроме того вы можете определить базовое поведение и хранить сколько лет живет то или иное животное - и исходя из этого сделать этот метод вообще в базовом классе

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants