Skip to content

Комаров Ярослав, задания 1 - 5#3

Open
YaroslavKomarov wants to merge 3 commits intoRTF-Angular-2021:masterfrom
YaroslavKomarov:Komarov-Yaroslav
Open

Комаров Ярослав, задания 1 - 5#3
YaroslavKomarov wants to merge 3 commits intoRTF-Angular-2021:masterfrom
YaroslavKomarov:Komarov-Yaroslav

Conversation

@YaroslavKomarov
Copy link

No description provided.

public isCardTiedToUser(cardId: any): any {

public isCardTiedToUser(cardId: string): boolean {
for(const user of this._users) {

Choose a reason for hiding this comment

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

Почему здесь не используешь this._users.forEach ?

Copy link
Author

Choose a reason for hiding this comment

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

Исходя из следующего Вашего комментария, не лучше ли будет в методах использовать просто "for"? Или хорошим тоном является все-таки использование "forEach"?

this._users.forEach(user => {
if (user.id === userId){
if (user.cards.find(card => card.id === cardId && card.pin === cardPin)){
return true;

Choose a reason for hiding this comment

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

Этот метод не отработает, он сделает ретурн для функции .foreach ( callbaack() { return }) , а не для родительской. Попробуй проверить. Авторизация всегда будет false.

} else {
return this.registerForUserNewCard(argsForChangeFunction);
}
}

Choose a reason for hiding this comment

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

Засчитано 3 бала

return this.takeUsersMoney(convertUnits);
}
return false;
}

Choose a reason for hiding this comment

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

Засчитано 3 бала

moneyUnits.forEach(moneyUnit => {
const tmpObj: IMoneyUnit = {
moneyInfo: {
denomination: (+moneyUnit.moneyInfo.denomination * coeff).toString(),

Choose a reason for hiding this comment

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

Номинал тут считать не надо. Потому что он фиксированный и не может быть дробным.
Тебе тут надо сумму посчитать и вызвать метод MoneyRepository.giveOutMoney передав туда это количество денег и валюту в которую надо превратить, метод MoneyRepository уже сам всё сделает.

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.

3 participants