Open
Conversation
SArchieEdu
reviewed
Sep 4, 2023
| export class SuccessControl { | ||
| create (type = '') { | ||
| // todo: implement logic | ||
| if (type === 'button') { |
Owner
There was a problem hiding this comment.
такое проще через switch case делать
| price = 1; | ||
|
|
||
| // todo: add implementation | ||
| // Смущает что получилось два одинаковых решения для Milk и для Sugar |
| } | ||
| start () { | ||
| // todo: add implementation | ||
| this.hero.name = 'Barbarian'; |
Owner
There was a problem hiding this comment.
лучше через конструктов, тк там есть аткая возможность
SArchieEdu
reviewed
Sep 4, 2023
| init () { | ||
| this.addGetSize(); | ||
|
|
||
| // Непонятно какая дополнительная логика должна быть добавлена |
Owner
There was a problem hiding this comment.
for (const child of this.compositeItem.children) {
child.accept(Visitor);
}|
|
||
| addGetSize () { | ||
| // todo: add implementation | ||
| this.compositeItem.getSize = () => { |
Owner
There was a problem hiding this comment.
addGetSize () {
let count = 0;
this.compositeItem.getSize = () => {
count += 1;
for (const child of this.compositeItem.children) {
count += child.getSize();
}
return count;
};
}| @@ -1,9 +1,21 @@ | |||
| // Непонятно для чего здесь класс Memento, раз нам не важно реализация состояния класса Hero, | |||
Owner
There was a problem hiding this comment.
export class Memento {
#state = {};
constructor (state = {}) {
this.#state = JSON.parse(state);
}
getState () {
return this.#state;
}
}
export class History {
#snapshots = [];
add (snapshot = {}) {
this.#snapshots.unshift(snapshot);
return this.#snapshots.at(0);
}
}
export class Hero {
#name = '';
#state = {
level: 1,
skills: [],
};
constructor(name = '', history = {}) {
this.#name = name;
this.history = history;
}
get state () {
return this.#state;
}
addSkill (skill) {
this.#state.skills.push(skill);
}
increaseLevel () {
this.#state.level += 1;
}
load (snapshot = {}) {
this.#state = snapshot.getState();
}
save () {
return this.history.add(new Memento(JSON.stringify(this.#state)));
}
}| // todo: implement | ||
| if (this.regExp.test(data)) { | ||
| /* | ||
| Непонятно для чего нужно свойство next, если можно записать короче: |
Owner
There was a problem hiding this comment.
для единообразия работы с элементами цепочки
|
|
||
| export class ProxyUser { | ||
| // Не понимаю зачем здесь это свойство | ||
| rights = []; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.