-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from liviaboscolo/Leticia_novas_classes
classes pessoa e usuario (ainda algumas duvidas)
- Loading branch information
Showing
3 changed files
with
45 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
from Pessoa import Pessoa | ||
from Livro import Livro #ainda a ser implementada - so coloquei p n dar erro no __init__ | ||
|
||
class Autor(Pessoa): | ||
def __init__(self, id, nome: str, email: str, lista_livros: Livro): | ||
super().__init__(id, nome, email) | ||
self.lista_livros = lista_livros | ||
|
||
def __str__(self) -> str: | ||
return f"Autor:\n{super().__str__()} | Lista de livros: {self.lista_livros}" | ||
|
||
@property | ||
def lista_livros(self): | ||
return self.lista_livros | ||
|
||
#provavelmente implementar ainda metodos especificos p adicionar, editar e remover a lista de livros do autor - mas acredito que deveriam ser de alguma outra classe |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
class Livro: | ||
pass |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
from abc import ABC, abstractmethod #para ser uma classe abstrata - não pode ser instaciada (não possui objetos próprios dela) | ||
import uuid #para atribuicao de ids as pessoas do nosso database | ||
|
||
class Pessoa(ABC): | ||
def __init__(self, id, nome: str, email: str): | ||
self.__id = str(uuid.uuid4()) | ||
self._nome = nome | ||
self.email = email | ||
|
||
def __str__(self) -> str: | ||
return f"Nome: {self.nome} | E-mail: {self.email}" | ||
|
||
@property | ||
def id(self): | ||
return self.__id | ||
|
||
@property | ||
def nome(self): | ||
return self._nome | ||
|
||
@property | ||
def email(self): | ||
return self.email | ||
|
||
@email.setter #importante caso a pessoa tenha mudado de email - recadastro | ||
def email(self, novo_email): | ||
self.email = novo_email |