You've seen code to mirror pictures in and you've seen code to mirror sounds . It should be pretty easy to use the mirrored string with the front mirrored to the back.
What will be an ideal response?
```
/**
* Clas s t h a t has methods t h a t ope rat e on a s t r i n g
* @author Barb Er icson er icson@cc . gat e ch . edu
* Copyr ight 2006
*/
public clas s StringWorker
{
// ////////// f i e l d s /////////////////////
/** s t r i n g to work on */
private St r ing aSt r ing ;
// //////////// c o n s t r u c t o r s /////////////
/**
* Cons t ruc tor t h a t t ak e the s t r i n g to work wi th
* @param t h e S t r i n g the s t r i n g to work wi th
*/
public StringWorker ( St r ing theSt r ing )
{
this . aSt r ing = theSt r ing ;
}
// ////////////// methods //////////////////
/**
* Method to mirror f r o n t of the s t r i n g to the
* back
* @return the new s t r i n g t h a t i s mirrored
*/
public St r ing mi r ror ( )
{
char [ ] charArray = this . aSt r ing . toCharArray ( ) ;
int mi r rorPoint = charArray . l eng th ;
int l a s t I n d e x = charArray . l eng th ¡ 1 ;
char theChar = charArray [ 0 ] ;
// loop up to mirror p o int
for ( int i = 0 ; i < mi r rorPoint ; i++)
{
theChar = charArray [ i ] ;
charArray [ l a s t I n d e x ¡ i ] = theChar ;
}
return new St r ing ( charArray ) ;
}
/**
* Main method f o r t e s t i n g
*/
public s tat ic void main ( St r ing [ ] args )
{
// t r y a s t r i n g wi th an even number of c h a r a c t e r s
StringWorker worker = new StringWorker ( "This i s a t e s t " ) ;
St r ing mString = worker . mi r ror ( ) ;
System . out . p r i n t l n (mString ) ;
// t r y one wi th an odd number
worker = new StringWorker ( "Try an odd number o f c h a r a c t e r s " ) ;
mString = worker . mi r ror ( ) ;
System . out . p r i n t l n (mString ) ;
}
}
```
You might also like to view...
A Baltimore business that once used in-house employees but now has those services done by a Hong Kong company is engaging in ________
Fill in the blank(s) with correct word
A custom date format set for a Date/Time field that contains the symbols mmm/dd/yy would display the date as ____.
A. July 4, 2016 B. 07/04/16 C. 7/4/2016 D. Jul/04/16
Case Based Critical Thinking Questions ? Case 2-2 Antoinette is part of a college department creating a number of student files with Microsoft Excel. She is working on a student retention project and wants to produce a worksheet that can alert faculty of student progress and current grade status. ? ? Antoinette's workbook has all the data entered and students' current grades displayed. She would like the current grade cells to display the value in red if it is less than 60. Antoinette needs to add _____ to the cell.
A. cell formatting B. conditional formatting C. highlighting D. fill color
A dropper installs a malicious program on a device, and it works with an entire program. Code injection inserts a segment of malicious code into another program. It carries only a short segment of code rather than an entire program.
Answer the following statement true (T) or false (F)