$24
Creating an e-mail Message Class
Understand the Application
e-mail. How we often communicate today…from Christmas lists, to pick up from the store lists, to-do lists, to one-liner messages…all examples of communication using an e-mail message.
Specifically we will write a Python3 program that will implement a simple class that will model an e-mail message.
The Program Spec
The task for this lab is to design and implement a class that will model an e-mail message. You will define the Message class. The Message will include a sender, recipient and body. The sender is the originator of the email message. The recipient is the receiver of the message. The body contains the text of the message.
Provide the following methods for the Message class:
A constructor with parameters self, sender and recipient. Set values for sender and recipient. Set body as an empty string.
A method append with parameters self and line. line contains the line of text to add to the body of the message. End message line with a newline character.
A method toString: Returns a string representation of the entire message. The entire message includes
the sender, the recipient and the body of the message. Example: “From: Student One\nTo: Student Two\nLunch today?\n”
Attached is a program that uses this class to create an e-mail message and print it.
Deliverable: yournameLab6.py Your source code solution and a copy of the run pasted into your source submission file. Be sure to comment out your run so that your .py file will still run in the grader test bed.
Input Error Checking: For simplicity a valid python file is provided to use your class. The filename is demo_message.py provided in webAccess.
Test Run Requirements: Use the provided demo_message.py file as your test run validator.
Here are some other tips and requirements:
Name the class Message
To run demo_message.py you will need to change CIS_117_Lab6Soln to the name of your deliverable (i.e. yournameLab6.py)
Keep the rest of the provided program test file demo_message.py intact
Run the demo_message.py program to use your class to make a Message and generate submission run output
Here is a sample run:
…
From: Bob
To: Santa
For Christmas, I would like:
Video games
World peace