In this task, we’re going to be simulating an email message. Some of the logic has been filled out for you in the email.py file. ● Open the file called email.py. ● Create a class definition for an Email which has four variables: has_been_read, email_contents, is_spam and from_address. ● The constructor should initialise the sender’s email address. ● The constructor should also initialise has_been_read and is_spam to false. ● Create a function in this class called mark_as_read which should change has_been_read to true. ● Create a function in this class called mark_as_spam which should change is_spam to true. ● Create a list called inbox to store all emails (note that you can have a list of objects). ● Then create the following methods: ○ add_email - which takes in the contents and email address from the received email to make a new Email object. ○ get_count - returns the number of messages in the store. ○ get_email - returns the contents of an email in the list. For this, allow the user to input an index i.e. get_email(i) returns the email stored at position i in the list. Once this has been done, has_been_read should now be true. ○ get_unread_emails - should return a list of all the emails that haven’t been read. ○ get_spam_emails - should return a list of all the emails that have been marked as spam. ○ delete - deletes an email in the inbox. Now that you have these set up, let’s get everything working! ● Fill in the rest of the logic for what should happen when the user inputs send/read/quit. Some of it has been done for you.

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

in python language

In this task, we’re going to be simulating an email message. Some of the logic has
been filled out for you in the email.py file.
● Open the file called email.py.
● Create a class definition for an Email which has four variables:
has_been_read, email_contents, is_spam and from_address.
● The constructor should initialise the sender’s email address.
● The constructor should also initialise has_been_read and is_spam to false.
● Create a function in this class called mark_as_read which should change
has_been_read to true.
● Create a function in this class called mark_as_spam which should change
is_spam to true.
● Create a list called inbox to store all emails (note that you can have a list of
objects).
● Then create the following methods:
○ add_email - which takes in the contents and email address from the
received email to make a new Email object.
○ get_count - returns the number of messages in the store.
○ get_email - returns the contents of an email in the list. For this, allow
the user to input an index i.e. get_email(i) returns the email stored
at position i in the list. Once this has been done, has_been_read
should now be true.
○ get_unread_emails - should return a list of all the emails that haven’t
been read.
○ get_spam_emails - should return a list of all the emails that have been
marked as spam.
○ delete - deletes an email in the inbox.
Now that you have these set up, let’s get everything working!
● Fill in the rest of the logic for what should happen when the user inputs
send/read/quit. Some of it has been done for you.

Expert Solution
steps

Step by step

Solved in 3 steps with 2 images

Blurred answer
Follow-up Questions
Read through expert solutions to related follow-up questions below.
Follow-up Question

PLEASE ASSIST ON THE BELOW REVIEW

Before the user can read an email, they have to see the emails. To achieve this, your program should first of all determine which emails have not been read and return that to the user. Then the user can choose. The emails should be numbered so that the user can provide the number as the index. Consider using the enumerate function to achieve this.

I realise that there are no emails within the email box , kindly add some dummy emails in this list so that at least there is something within the inbox list.

Do the same for marks as spam. Present to the user all the emails that have not been marked as spam for the user to mark as spam.

Most importantly, your code is not well indented. Try to work on your indentation as it makes your code easier to read and the logic easier to follow. Indentation is key in python to define the blocks of statements. The number of spaces must be uniform in a block of code. It is preferred to use four whitespaces instead of tabs to indent in python.

Solution
Bartleby Expert
SEE SOLUTION
Knowledge Booster
Random Class and its operations
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education