Extend the form letter recipe to take an input of a pet's name and type, and reference the pet in the form letter. "Your pet "+petType+","+petName+" will love our offer!" might generate "Your pet poodle, Fifi, will love our offer!". See the FormLetterGenerator class in the directory bookClassesFinal.
What will be an ideal response?
```
? ?
? Method to generate a form l e t t e r
? @param t i t l e t h e p e r s o n ’ s t i t l e (Mr . , Mrs . , Dr . )
? @param lastName t h e l a s t name f o r t h e r e c i p i e n t
? @param c i t y t h e name o f t h e c i t y f o r t h e r e c i p i e n t
? @param e y e C o l o r t h e e y e c o l o r o f t h e r e c i p i e n t
? @param petName t h e name o f t h e p e t
? @param petType t h e t y p e o f animal ( c a t , dog , e t c )
?/
public void w r i t e L e t t e r ( S t r i n g t i t l e , S t r i n g lastName ,
S t r i n g city , S t r i n g eyeColor ,
S t r i n g petName, S t r i n g petType )
{
S t r i n g f i l e N a m e = lastName + ” L e t t e r . t x t ” ;
// t r y t o open t h e f i l e and w r i t e t o i t
try {
// c r e a t e t h e b u f f e r e d w r i t e r t o u s e t o w r i t e t h e f i l e
BufferedWriter writer =
new B u f f e r e d W r i t e r (new F i l e W r i t e r ( f i l e N a m e ) ) ;
// w r i t e t h e b e g i n n i n g
w r i t e B e g i n n i n g ( w r i t e r , t i t l e , lastName ) ;
// w r i t e t h e body o f t h e l e t t e r
writeBody ( w r i t e r , c i t y , e y e C o l o r , petName , petType ) ;
// w r i t e t h e e n d i n g
writeEnding ( w r i t e r ) ;
// c l o s e t h e f i l e
writer . close ( ) ;
} catch ( E x c e p t i o n ex ) {
System . out . p r i n t l n ( ” E r r o r w r i t i n g t o ” + f i l e N a m e ) ;
}
}
```
You might also like to view...
The basic generic functional interface ________ in package java.util.function contains method accept that takes a T argument and returns void. Performs a task with its T argument, such as outputting the object, invoking a method of the object, etc.
a. Consumer
What color is displayed if each color in the RGB system is saturated?
A) Black B) Brown C) White D) Gray
People with limited legal ____ are vulnerable because they depend on the goodwill and attention of their guardians.
A. soliloquy B. autonomy C. liberty D. free speech
If you want to associate alternate text with a slice, you enter the text in the Message box in the Slice Options dialog box.
Answer the following statement true (T) or false (F)