-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmessage.py
More file actions
22 lines (21 loc) · 783 Bytes
/
message.py
File metadata and controls
22 lines (21 loc) · 783 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#esercizio corretto
class Message:
def __init__ (self, destinatario, mittente):
self._destinatario = destinatario
self._mittente = mittente
self._messaggio = [] #oppure self._messaggio = []
def destinatario(self) :
return self._destinatario
def mittente(self) :
return self._mittente
def messaggio(self):
return self._messaggio
def append(self, riga):
self._messaggio.append(riga) #Append riga oppure questo metodo
def toString(self):
messaggio_formattato = " ".join(self._messaggio)
print (f"Da:{self._mittente}\nA:{self._destinatario}\nMessaggio:\n{messaggio_formattato}")
mess = Message("riccardo", "lorenzo")
mess.append("Ciao, come stai?")
mess.append("e sei andato ieri a funghi?")
mess.toString()