Twoim zadaniem jest napisanie klasy Customer w języku Python, która będzie reprezentować dane klienta.
-
prywatne pole
name(typ: string): przechowuje imię klienta -
prywatne pole
email(typ: string): przechowuje adres email klienta
-
__init__(self, name: str, email: str): konstruktor, który inicjalizuje obiekt klasyCustomerprzyjmując wartości dlaname(imię klienta) iemail(adres email klienta). -
name(self) -> str: getter zwracający wartość_name. -
name(self, value: str) -> None: setter ustawiający wartość_namena podstawie podanej wartościvalue. Jeśli wartośćvaluejest pusta, powinien zostać zgłoszony wyjątekValueErrorz komunikatem "Name cannot be empty". -
email(self) -> str: getter zwracający wartość_email. -
email(self, value: str) -> None: setter ustawiający wartość_emailna podstawie podanej wartościvalue. Jeśli wartośćvaluenie jest poprawnym adresem email, powinien zostać zgłoszony wyjątekValueErrorz komunikatem "Invalid email format". -
validate_email(self, email: str) -> bool: metoda prywatna sprawdzająca poprawność formatu adresu email. -
save_to_database(self) -> None: metoda zapisująca dane klienta (na potrzeby zadania wystarczy do do csv).
customer = Customer("John Doe", "[email protected]")
print(customer.name) # Output: John Doe
print(customer.email) # Output: [email protected]
customer.name = "Jane Smith"
customer.email = "[email protected]"
customer.save_to_database()