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

CodeWars, Class assignment, Severe polymorphism and inheritance hierarchy, Calculating a person's age #21

Open
wants to merge 12 commits into
base: Pyzhov_Viktor
Choose a base branch
from

Conversation

Victor2004
Copy link

No description provided.

All tasks
rpgsaga Задание на классы
22 вариант. Фильм (метод - проиграть фильм)
Задание Суровый полиморфизм и иерархия наследования
22 вариант. Фильм
Задание Вычисление возраста человека
@jskonst jskonst changed the base branch from master to Pyzhov_Viktor November 18, 2023 19:11
Comment on lines +120 to +121
saga/yarn.lock
Copy link
Contributor

Choose a reason for hiding this comment

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

если yarn не используете - то просто удалите файлы

saga/yarn.lock
saga/.yarnrc.yml
saga/package.json
Copy link
Contributor

Choose a reason for hiding this comment

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

а вот этот файл должен быть в рапозитории

@@ -1,16 +1,58 @@
import { Phone } from './phone';
// import { Art } from './art';
Copy link
Contributor

Choose a reason for hiding this comment

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

все что не нужно - удаляйте - тут можете оставить в целом пример только вызова ваших классов

@@ -0,0 +1,20 @@
export abstract class Art {
title: string;
year1: number;
Copy link
Contributor

Choose a reason for hiding this comment

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

судя по всему год я могу сделать отрицательным - и почему он year1 ?


constructor(title: string, year: number, director: string) {
this.title = title;
this.year1 = year;
Copy link
Contributor

Choose a reason for hiding this comment

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

вот тут как раз надо

Suggested change
this.year1 = year;
this.year = year;

чтобы вызвался set

}

set year(year: number) {
this.year1 = year;
Copy link
Contributor

Choose a reason for hiding this comment

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

добавьте проверку и бросайте exception если он не попадает в диапазон

Comment on lines 13 to 23
const now = new Date();
const days = now.getDate() - this.dateBirth.getDate();
const months = now.getMonth() - this.dateBirth.getMonth() + 1;
const years = now.getFullYear() - this.dateBirth.getFullYear();
if (this.dateBirth.getDate() == now.getDate() && this.dateBirth.getMonth() == now.getMonth() && this.dateBirth.getFullYear() == now.getFullYear()) {
return "0 days, 0 months, 0 years";
}
if (months < 0 || years < 0) {
return "Invalid date"
}
return `${days} days, ${months} months, ${years} years`;
Copy link
Contributor

Choose a reason for hiding this comment

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

не не - надо использовать timestamp и вычесть 1 дату из другой

return `${this.title}, ${this.director}, ${this.year}`;
}

pages: number;
Copy link
Contributor

Choose a reason for hiding this comment

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

опчть же - если поле не приватное я могу сделать его отрицательным?


constructor(title: string, year: number, director: string, pages: number) {
super(title, year, director);
this.pages = pages >= 1 ? pages : 1;
Copy link
Contributor

Choose a reason for hiding this comment

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

используйте set и вызовите его тут - если значение вас не устаривает - то бросайте exception

Основные отличия от ТЗ:
- У всех классов есть атака ближнего боя;
- Заклинание "Заворожение" маг может использовать только 3 раза.
Fix rpgsaga to comply with OOP,
returned old files that I deleted for no reason,
started writing unit tests
should simulate the first game scenarios
fixing a small bug in the logger
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