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...
Provide a definition of participatory design. Give three arguments for and three arguments against participatory design.
What will be an ideal response?
Here is a collection of if and if-else statements with semicolons in various places. Assume all variables have been declared and initialized. Which of these are correct and are likely to give the programmers intent? Which are correct but unlikely to give the programmer's intent? Give the error for the remaining.
a) if ( a > b ); a = b; else b = a; b) if(a > b ) a = b; else; b = a; c) if(a > b ) a = b; else b = a; d) if(a > b) a = b else b = a; e) if( x !=0 ) a = a / x