Guest User

Untitled

a guest
Jan 21st, 2018
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.05 KB | None | 0 0
  1. // 10-7
  2.     public String convertName( String name )
  3.     {
  4.         // TODO complete method
  5.         String last = name.substring( 0, name.indexOf( ',' ) );
  6.         String first = name.substring( name.indexOf( ',' ) + 1 ).trim();
  7.         return first + " " + last;
  8.     }
  9.  
  10.  
  11.     // 10-8
  12.     public String negate( String str )
  13.     {
  14.         // TODO complete method
  15.         return str.replace( '1', 'a' )
  16.             .replace( '0', 'b' )
  17.             .replace( 'a', '0' )
  18.             .replace( 'b', '1' );
  19.     }
  20.  
  21.  
  22.     // 10-9
  23.     public boolean isConstant( String s )
  24.     {
  25.         // TODO complete method
  26.         return s.equals(s.substring( 1 ) + s.charAt( 0 ));
  27.     }
  28.  
  29.  
  30.     // 10-10
  31.     public String removeComment( String str )
  32.     {
  33.         // TODO complete method
  34.         if ( str.indexOf( "/*" ) != -1 && str.indexOf( "*/" ) != -1 )
  35.         {
  36.             return str.substring( 0, str.indexOf( "/*" ) )
  37.                 + str.substring( str.indexOf( "*/" ) + 2 );
  38.         }
  39.         else
  40.         {
  41.             return str;
  42.         }
  43.     }
Add Comment
Please, Sign In to add comment