Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- This class models a simple letter.
- */
- public class Letter
- {
- private String from;
- private String to;
- private String text;
- /**
- Constructs a letter with a given sender and recipient.
- @param from the sender
- @param to the recipient
- */
- public Letter(String from, String to)
- {
- this.from = from;
- this.to = to;
- text = "";
- }
- /**
- Adds a line to the body of this letter.
- */
- public void addLine(String line)
- {
- text = text +line + "\n";
- }
- /**
- Gets the text of this letter.
- */
- public String getText()
- {
- String output = "Dear " + to + ":\n\n";
- output += text + "\nSincerely,\n\n" + from + ".";
- return output;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement