Question

PYTHON PROGRAM QUESTION

PYTHON PYTHON PYTHON P Y T HO NPython programmingSample run: From: Bob To: Santa For Christmas, I would like: Video games World peace From: Bob To: Tooth Fairy Merry Christmas to my best friend I am wishing y。u blessings and joy this Christmas. From: Bob To: Johnson Happy Thanksgiving to you and your family.

PYTHON PROGRAMMING ASSIGNMENT

0 0
Add a comment Improve this question Transcribed image text
Answer #1

all codes as follow:

*************************************************************************************

class Message(object):
    def __init__(self, recipient, sender, text):
        self.recipient=recipient
        self.sender=sender
        self.text=text

    def append(self, msg):
        sef.text=self.text+msg
        return self.stext


    def toString(self):
        return "From: "+self.sender+" \nTo:"+self.recipient+" \n"+self.text


********************************************************************************************

#from Message import Message
class Mailbox:
    def __init__(self):
        self.mesg=[]

    def addMessage(self, Message):
        self.mesg.append(Message)

    def getMessage(self, index):
        return self.mesg[index]

    def removeMessage(self, index):
        self.mesg.pop(index)


************************************************************************************

import Message
from Mailbox import Mailbox
class MailboxDemo:
    m1=Message.Message("Bob", "Santa", "For Christmas I would Like:\nvideo games \nworld peace")
    m2=Message.Message("Bob", "Tooth fairy", "Merry Christmas to my bestfriend \nI am wishing you blessing and joy this christmas")
    m3=Message.Message("Bob","Johnson","Happy Thanksgiving to you and your family")
    mb=Mailbox()
    #print(mb.getMessage[0])
    #ans=m1.toString()
    print(m1.toString()+"\n")
    print(m2.toString()+"\n")
    print(m2.toString()+"\n")


**************************************************************************************

hope this helps, comment on answer for any query

Add a comment
Know the answer?
Add Answer to:
PYTHON PROGRAM QUESTION Python programming PYTHON PROGRAMMING ASSIGNMENT PYTHON PYTHON PYTHON P Y T HO N
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT