Classe Employee

L'obiettivo è implementare una classe Employee che rappresenti i dati e le operazioni di un dipendente in un'azienda. Un Employee ha quattro attributi:

  • name: una stringa che rappresenta il nome del dipendente.

  • id: una stringa che rappresenta l'identificativo del dipendente.

  • department: una stringa che rappresenta il reparto del dipendente.

  • salary: un float che rappresenta lo stipendio mensile del dipendente.

La classe Employee dovrebbe avere i seguenti metodi:

  • get_details(): Restituisce una rappresentazione in forma di stringa di un Employee. Questa stringa dovrebbe contenere il name, l'id e il department dell'Employee con il seguente formato: “Name: <NAME>, ID: <ID>, Department: <DEPARTMENT>”.

  • calculate_annual_salary(): Restituisce un float che rappresenta lo stipendio annuale dell'Employee. Lo stipendio annuale si calcola moltiplicando lo stipendio mensile per 12.

Input

Output

john = Employee('John Doe', 'JD01', 'Engineering', 5000.0); print(john.get_details()); print(john.calculate_annual_salary()); john.department = 'Management'; john.salary = 7000; print(john.get_details()); print(john.calculate_annual_salary())

Name: John Doe, ID: JD01, Department: Engineering
60000.0
Name: John Doe, ID: JD01, Department: Management
84000.0

Constraints

Time limit: 2 seconds

Memory limit: 512 MB

Output limit: 1 MB

To check your solution you need to sign in
Sign in to continue