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

Solution #1200

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Solution #1200

wants to merge 1 commit into from

Conversation

vladyslav-tmf
Copy link

No description provided.

Comment on lines +2 to +8
def __init__(self, name: str) -> None:
self.name = name
self.skills: list[str] = []

def learn_skill(self, skill: str) -> None:
if skill not in self.skills:
self.skills.append(skill)
Copy link

Choose a reason for hiding this comment

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

you can not use if in learn_skill method, if you have created list in the __init__ method, because you already have this list

Copy link
Author

@vladyslav-tmf vladyslav-tmf Oct 2, 2024

Choose a reason for hiding this comment

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

Method __init__ creates an empty list for storing skills.
The learn_skill method adds a new skill, but first checks if the list already contains this skill to avoid duplicates.
So, in my opinion, the verification is important.

class FrontendDeveloper(SoftwareEngineer):
def __init__(self, name: str) -> None:
super().__init__(name)
self.skills.extend(["JavaScript", "HTML", "CSS"])
Copy link

Choose a reason for hiding this comment

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

I guess, if you pass only name to patent class, you don't have skills attribute in the current instanse , and i think, you can write like this: self.skills = ["JavaScript", "HTML", "CSS"]
it is created skills attribute in this instance
and the same in other classes

Copy link
Author

@vladyslav-tmf vladyslav-tmf Oct 2, 2024

Choose a reason for hiding this comment

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

The self.skills attribute is already initialized as an empty list in the parent SoftwareEngineer class when the __init__ method is called. In child classes, such as FrontendDeveloper, there is no need to create it again.
The use of self.skills.extend(...) in child classes is correct because it simply extends the existing list of skills inherited from the parent class.
In other words, when you create an instance of the FrontendDeveloper class, the skills attribute will be a copy of the skills list inherited from the parent class, but it will be unique for each instance.

class BackendDeveloper(SoftwareEngineer):
def __init__(self, name: str) -> None:
super().__init__(name)
self.skills.extend(["Python", "SQL", "Django"])
Copy link

Choose a reason for hiding this comment

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

check another comments

class AndroidDeveloper(SoftwareEngineer):
def __init__(self, name: str) -> None:
super().__init__(name)
self.skills.extend(["Java", "Android studio"])
Copy link

Choose a reason for hiding this comment

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

check another comments

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