Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I need help with this 2 questions and the answers have to be in Python 3.x. Please help. Thank you! 7. Provide a class for

image text in transcribed

I need help with this 2 questions and the answers have to be in Python 3.x. Please help. Thank you!

7. Provide a class for authoring a simple letter. In the constructor, supply the names of the sender and the recipient: der-init-(self, letterFrom, etterTo) Supply a method def addLine(self, line) to add a line of text to the body of the letter. Supply a method def getText(self) that returns the entire text of the letter. The text has the form: Dear recipient name: blank line first line of the body second line of the body last line of the body blank line Sincerely, blank line sender name Also supply a driver program that prints the following letter: Dear John: 1 I am sorry we must part. I wish you all the best. Sincerely, Mary Construct an object of the Letter class and call addLine twice. 2. Design a class called Color. The fields of the class are three decimals for Red, Green, and Blue components in the range 0 to 1, inclusive (0 indicates Black and 1 indi- cates White). Add checks to ensure that the values are always in the given range Provide addition and subtraction operators for the color class. Include saturation in the addition and subtraction: if any component goes less than 0 or greater than 1, assign them 0 or 1, respectively

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Essential SQLAlchemy Mapping Python To Databases

Authors: Myers, Jason Myers

2nd Edition

1491916567, 9781491916568

More Books

Students also viewed these Databases questions