Question
Provide a class for authoring a simple letter. In theconstructor, supply the names of the sender and therecipient: public Letter(String from, String to) Supply a
Provide a class for authoring a simple letter. In theconstructor, supply the names of the sender and therecipient:
public Letter(String from, String to)
Supply a method
public void addLine(String line)
to add a line of text to the body of the letter.
Supply a method
public String getText( )
That returns the entire text of the letter. The text has theform:
Dear recipientname:
blankline
firstline of the body
second line of thebody
.....
last line of thebody
blankline
sincerely,
blankline
sendername
Also supply a program LetterPrinter that prints thisletter.
Dear John:
I am sorry we must part.
I wish you all the best
Sincerely,
Mary
Construct an object of the letter class and call addLinetwice.
Step by Step Solution
3.52 Rating (159 Votes )
There are 3 Steps involved in it
Step: 1
Letterjava package myPackage import javalang public class Letter String from String t...Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started