-
Notifications
You must be signed in to change notification settings - Fork 34
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
base: Pyzhov_Viktor
Are you sure you want to change the base?
Conversation
rpgsaga Задание на классы 22 вариант. Фильм (метод - проиграть фильм)
Задание Суровый полиморфизм и иерархия наследования 22 вариант. Фильм
Задание Вычисление возраста человека
saga/yarn.lock |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
а вот этот файл должен быть в рапозитории
rpgsaga/saga/src/index.ts
Outdated
@@ -1,16 +1,58 @@ | |||
import { Phone } from './phone'; | |||
// import { Art } from './art'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
все что не нужно - удаляйте - тут можете оставить в целом пример только вызова ваших классов
rpgsaga/saga/src/art.ts
Outdated
@@ -0,0 +1,20 @@ | |||
export abstract class Art { | |||
title: string; | |||
year1: number; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
судя по всему год я могу сделать отрицательным - и почему он year1 ?
rpgsaga/saga/src/art.ts
Outdated
|
||
constructor(title: string, year: number, director: string) { | ||
this.title = title; | ||
this.year1 = year; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
вот тут как раз надо
this.year1 = year; | |
this.year = year; |
чтобы вызвался set
rpgsaga/saga/src/art.ts
Outdated
} | ||
|
||
set year(year: number) { | ||
this.year1 = year; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
добавьте проверку и бросайте exception если он не попадает в диапазон
rpgsaga/saga/src/birthday.ts
Outdated
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`; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
не не - надо использовать timestamp и вычесть 1 дату из другой
rpgsaga/saga/src/book.ts
Outdated
return `${this.title}, ${this.director}, ${this.year}`; | ||
} | ||
|
||
pages: number; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
опчть же - если поле не приватное я могу сделать его отрицательным?
rpgsaga/saga/src/book.ts
Outdated
|
||
constructor(title: string, year: number, director: string, pages: number) { | ||
super(title, year, director); | ||
this.pages = pages >= 1 ? pages : 1; |
There was a problem hiding this comment.
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
No description provided.