
Database System Concepts
7th Edition
ISBN: 9780078022159
Author: Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher: McGraw-Hill Education
expand_more
expand_more
format_list_bulleted
Question
![4. The following code should define the class Text Message, create a list of instances of that
class in the main method, and call instance methods to display the message chain.
Unfortunately, there are errors in this code - circle at least 4 errors and fix each one.
class Text Message:
def init (self, sender, receiver, message, timestamp):
self.sender = sender
self.receiver = receiver
self.message = message
arbioms to bus self.timestamp = timestamp
if
def getSender (self):
return sender
def getReceiver (self):
def getMessage(self):
return self.receiver
def getTimestamp():
def main():
return self.message
/self
return self.timestamp
textChain =
_name
Self-sender
[]
"142026"
for message in textChain:
textChain.append(TextMessage("Ava", "Basil", "Dinner at 6?", 142026))
textChain.append (Text Message("Basil", "Ava", "Sure! Meet outside
Blanch?"))
print (strmsg)
== "__main__":
main()
botail
3
07 E
omstayebut
strMsg = message.getSender() +
to
+ message.getReceiver() +
at + message.getTimestamp () + ": " + message.getMessage()](https://content.bartleby.com/qna-images/question/0aa27a28-efdb-4d0f-aad3-266fe3536dfa/41ef3c90-6b2f-46d8-89d8-342dda3fb830/yl3c64_thumbnail.jpeg)
Transcribed Image Text:4. The following code should define the class Text Message, create a list of instances of that
class in the main method, and call instance methods to display the message chain.
Unfortunately, there are errors in this code - circle at least 4 errors and fix each one.
class Text Message:
def init (self, sender, receiver, message, timestamp):
self.sender = sender
self.receiver = receiver
self.message = message
arbioms to bus self.timestamp = timestamp
if
def getSender (self):
return sender
def getReceiver (self):
def getMessage(self):
return self.receiver
def getTimestamp():
def main():
return self.message
/self
return self.timestamp
textChain =
_name
Self-sender
[]
"142026"
for message in textChain:
textChain.append(TextMessage("Ava", "Basil", "Dinner at 6?", 142026))
textChain.append (Text Message("Basil", "Ava", "Sure! Meet outside
Blanch?"))
print (strmsg)
== "__main__":
main()
botail
3
07 E
omstayebut
strMsg = message.getSender() +
to
+ message.getReceiver() +
at + message.getTimestamp () + ": " + message.getMessage()
Expert Solution

This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
Step by stepSolved in 2 steps

Knowledge Booster
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
- 1) Through BlueJ, the class must define a method called isSpace that allows the book club staff to determine whether there is enough capacity for a group to attend. This method must take a single integer parameter representing the size of the group, and return a boolean result. The method must work as follows: If the value of the parameter is less-than or equal-to 0 then the method must return false. This case has priority over those following. If the value of the parameter is less-than or equal-to the space left in the book club (use the capacity and occupancy values in the to work this out) then the method must return true. Otherwise (i.e., if there is not space in the book club for the whole group) then the method must return false. 2) This method must not change the state of the BookClub object. In other words, both the current number of occupants and the capacity of the club must be exactly the same after it is called as it was before (Note that the return type of this method…arrow_forwardFor the programming language Javaarrow_forwardWhat is the main difference between a struct and a class? (More than 1 answer can be chosen)arrow_forward
- 17. Create a class ShuffleCipher that implements the interface MessageEncoder, as described in Exercise 15. The constructor should have one parameter called n. Define the method encode so that the message is shuffled n times. To perform one shuffle, split the message in half and then take characters from each half alternately. For example, if the message is abcdefghi, the halves are abcde and fghi. The shuffled message is afbgchdie. (Hint: You may wish to define a private method that performs one shuffle.)arrow_forward5. Given the Java Point class (which contains two private variables x and y and constructors that allows creating a point object with known x and y values as well as other methods such as equals( ), toString( ) etc), (a). define a new class called Circle that contains private two variables: center which is a Point object from the Point class and radius which is of type double. The Circle class must have the following methods: (b). add a constructor which creates a circle object using a center point with x and y values and a radius as its parameters. (c). add a default constructor. ( (d). add an equals() method that can compare if any object is equal to a Circle object (two circle objects are equal if they have the same center point with the same radius). (e). add a toString() method that prints a Circle object with the center point and radius.arrow_forwardWrite a class definition line and a one line docstring for the class Dog. Write an __init__ method for the class Dog that gives each dog its own name and breed. Test this on a successful creation of a Dog object.>>> import dog>>> sugar = dog.Dog('Sugar', 'border collie')>>> sugar.name'Sugar'>>> sugar.breed'border collie' Add a data attribute tricks of type list to each Dog instance and initialize it in __init__ to the empty list. The user does not have to supply a list of tricks when constructing a Dog instance. Make sure that you test this successfully.>>> sugar.tricks[] Write a method teach as part of the class Dog. The method teach should add a passed string parameter to tricks and print a message that the dog knows the trick.>>> sugar.teach('frisbee')Sugar knows frisbeearrow_forward
arrow_back_ios
arrow_forward_ios
Recommended textbooks for you
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education

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)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON

Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON

C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON

Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning

Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education