Skip to content

Дюкин Петр // ts-2#7

Open
diukin wants to merge 3 commits into
RTF-Angular-2021:masterfrom
diukin:master
Open

Дюкин Петр // ts-2#7
diukin wants to merge 3 commits into
RTF-Angular-2021:masterfrom
diukin:master

Conversation

@diukin
Copy link
Copy Markdown

@diukin diukin commented Apr 8, 2021

No description provided.

Comment thread src/task_1/index.ts Outdated
export class MoneyRepository {
private _repository: any;
constructor(initialRepository: any) {
private _repository: Array<object>;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Object в типизации - страшный грех, также как и any

Comment thread src/task_1/index.ts Outdated
const rubles = [10, 50, 100, 500, 1000, 5000];
this._repository.forEach(e => {
for (let key in e)
if (e['moneyInfo']['currency'] === currency && temp >= e['count']
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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

Comment thread src/task_3/index.ts Outdated
public changeUserSettings(option: UserSettingOptions, argsForChangeFunction: any): any {

public changeUserSettings(option: UserSettingOptions, argsForChangeFunction: string): boolean {
return argsForChangeFunction === option[0] ? this.changeUserName(argsForChangeFunction) :
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Одно тернарное выражение в другом тернарном выражении очень запутывает, не надо так

Comment thread src/task_4/index.ts Outdated
public convertMoneyUnits(fromCurrency: Currency, toCurrency: Currency, moneyUnits: any): any {

public convertMoneyUnits(fromCurrency: Currency, toCurrency: Currency, moneyUnits: IMoneyUnit[]): IMoneyUnit[] {
const K = fromCurrency === Currency.RUB ? 70 : 1/70;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Математика в компьютере работает не так как в обычной жизни.
Когда условие попадет во вторую часть тернарного выражения коэффициент будет равен 0.014285714285714285 что сразу сломает все дальнейшие вычисления

Comment thread src/task_4/index.ts Outdated
public convertMoneyUnits(fromCurrency: Currency, toCurrency: Currency, moneyUnits: IMoneyUnit[]): IMoneyUnit[] {
const K = fromCurrency === Currency.RUB ? 70 : 1/70;
let res: IMoneyUnit[] = [];
for (var e of moneyUnits) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Для обхода массива следует использовать методы объекта массива

Comment thread src/task_5/index.ts Outdated
if (!this._authorizedUser) return false;
this._moneyRepository.takeMoney(moneyUnits);
const sum = moneyUnits.reduce((sum, unit) => {
return sum + unit.count * (+unit.moneyInfo.denomination.match(/\d/g).join(''));}, 0);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Неявное преобразование - зло

Comment thread src/task_1/index.ts
else this._repository.push(unit);
})
}
} No newline at end of file
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

зачтено 1 балл

Comment thread src/task_2/index.ts
if (typeof user === "undefined") return false
card = user.cards.filter(x => x.id === cardId)[0];
return typeof card !== "undefined" ? cardPin === card.pin : false;
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

1 балов

Comment thread src/task_3/index.ts
case UserSettingOptions.surname:
return this.changeUserSurname(argsForChangeFunction);
}
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

1 балл

Comment thread src/task_4/index.ts
return moneyUnits.count * denomination * 70;
}
return 0;
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

1 балл

Comment thread src/task_5/index.ts
if (this._authorizedUser)
return Boolean(this._currencyConverterModule.convertMoneyUnits(fromCurrency, toCurrency, moneyUnits));
return false;
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

1 балл

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