Question
import java.util.ArrayList; public class Letter { String sender, recipient; ArrayList lines; // The actual contents of the letter, each line stored individually int numLines; //
import java.util.ArrayList; public class Letter { String sender, recipient; ArrayList
public class LetterTester { public static void main(String[] args) { Letter dearJohn = new Letter("Sally","John"); dearJohn.addLine("I'm sorry but it's just not going to work out."); dearJohn.addLine("I'm taking the dog."); dearJohn.addLine("I'm keeping the ring."); System.out.println(dearJohn.getText()); System.out.println(" Letter length " + dearJohn.getNumberOfLines() + " lines"); System.out.println(" Expected: Dear John: I'm sorry but it's just not going to work out. I'm taking the dog. I'm keeping the ring. Sincerely, Sally "); System.out.println("Letter length 3 lines"); dearJohn.removeLine(2); System.out.println(dearJohn.getText()); System.out.println(" Letter length " + dearJohn.getNumberOfLines() + " lines"); System.out.println(" Expected: Dear John: I'm sorry but it's just not going to work out. I'm keeping the ring. Sincerely, Sally "); System.out.println("Letter length 2 lines"); dearJohn.removeLine(2); System.out.println(dearJohn.getText()); System.out.println(" Letter length " + dearJohn.getNumberOfLines() + " lines"); System.out.println(" Expected: Dear John: I'm sorry but it's just not going to work out. Sincerely, Sally "); System.out.println("Letter length 1 lines"); } }
Step by Step Solution
There are 3 Steps involved in it
Step: 1
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