Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // 10-7
- public String convertName( String name )
- {
- // TODO complete method
- String last = name.substring( 0, name.indexOf( ',' ) );
- String first = name.substring( name.indexOf( ',' ) + 1 ).trim();
- return first + " " + last;
- }
- // 10-8
- public String negate( String str )
- {
- // TODO complete method
- return str.replace( '1', 'a' )
- .replace( '0', 'b' )
- .replace( 'a', '0' )
- .replace( 'b', '1' );
- }
- // 10-9
- public boolean isConstant( String s )
- {
- // TODO complete method
- return s.equals(s.substring( 1 ) + s.charAt( 0 ));
- }
- // 10-10
- public String removeComment( String str )
- {
- // TODO complete method
- if ( str.indexOf( "/*" ) != -1 && str.indexOf( "*/" ) != -1 )
- {
- return str.substring( 0, str.indexOf( "/*" ) )
- + str.substring( str.indexOf( "*/" ) + 2 );
- }
- else
- {
- return str;
- }
- }
Add Comment
Please, Sign In to add comment