ユーザーの文字列値を配列に取り込むコードは既に記述しています。また、それらを印刷する際のコードも書きました。
私が抱えている問題はcharConvert()
、使用可能な文字列配列からメソッドに char 値を与え、その文字を変換してから文字列配列内の文字を置き換える方法を理解することです。
import java.util.Scanner;
public class zrwilliams_ROT13Arrays {
private static Scanner get = new Scanner ( System.in );
public static void main ( String args[] ){
String[] sentences = new String[5];
getSentences ( sentences );
displayOriginal ( sentences );
charConvert( );
for ( char temp = 'A'; temp <= 'Z'; temp++ ) {
System.out.printf ( "%c converts to %c\n", temp, charConvert(temp));
}
}
/**
* getSentences
*
* This method allows the user to enter text into each of the
* element of the String array that it receives.
*
* @param sentences An array of String[] data
* @return None
*/
public static void getSentences ( String[] sent ) {
System.out.println ( "Enter your 5 sentences below: " );
System.out.print ( "\n" );
int a = 1;
for ( int x = 0 ; x < sent.length; x++ ) {
System.out.printf ( "Sentence %d> ", a );
sent[x] = get.nextLine();
a = a + 1;
}
}
/**
* displayOriginal
*
* This method displays all of the elements of the array of
* String data that it receives, line by line (element by element).
*
* @param sentences An array of String[] data
* @return None
*/
public static void displayOriginal ( String[] sent ) {
System.out.print ( "\nThe original text: \n" );
for ( int x = 0; x < sent.length; x++ ) {
System.out.println ( sent[x] );
}
}
/**
* charConvert
d *
* This method will take one char value as a parameter and convert
* it to its appropriate ROT13 equivalent. The return value will be the
* new ROT13 char equivalent.
*
* This method will not do any output.
*
* @param toConvert A character to convert as a char
* @return The new ROT13 equivalent value as a char
*/
public static void charConvert ( String[] sent ) {
}
/**
* convertSentence
*
* This method will do the actual conversion of a String of data to its
* ROT13 equivalent in 5-character chunks of data. It should call on
* the charConvert() method to do the actual character conversion for each
* individual character. In other words, individual character conversion
* should not happen within this method.
*
* This method will not do any output.
*
* @param sentence A String variable to convert
* @return The 5-characters in a group ROT13 result as a String
*/
public static void convertSentence ( String[] sent ) {
}
/**
* displayROT13
*
* This method will display in ROT13 format all of the elements of the
* array of String data that it receives . It will need to call on the
* method convertSentence() to convert each string before it displays it.
* Note that the original array should not be modified with ROT13 data.
*
* @param sentences An array of String[] data
* @return None
*/
public static void displayROT13 ( String[] sent ) {
}
/**
* displayCombinedROT13
*
* This method takes an array of String data and combines all of the Strings
* into a single String that is then processed by the convertSentence()
* method. The method should essentially display the same results as the
* displayROT13() method, except that there won't be separate lines of
* output but rather one large result instead.
*
* @param sentences An array of String[] data
* @return None
*/
public static void displayCombinedROT13 ( String[] sent ) {
}
}