私はコーディングの完全な初心者であり、助けが得られるかどうか疑問に思っていました
私はこのプロジェクトを見てもらい、基本的に私がする必要があるのは次のとおりです。
2 つの実行可能プログラムを作成します。翻訳プログラムと辞書プログラム。プログラムは任意の言語で記述できます。
翻訳プログラムは辞書プログラムに英単語を渡します。辞書プログラムは外国語を翻訳して返します。翻訳プログラムは英語の単語とその翻訳をファイルに出力します。
辞書プログラムは英単語を検索し、その外国語への翻訳を返します。辞書プログラムには、選択した数の英単語を別の言語に翻訳する機能があります。辞書プログラムが英単語を翻訳する言語は、生徒が決定します。辞書プログラムには、少なくとも 15 の英単語を外国語に翻訳する機能があります。"
現在、辞書プログラムが翻訳プログラムを呼び出すのに問題があります。私のインストラクターは、ステートメントを使用するように私たちに言いました
Process proc = Runtime.getRuntime().exec("java -jar Translate.jar");
InputStream in = proc.getInputStream();
InputStream err= proc.getErrorStream();
現在の問題は、私のプログラムが jar ファイルにアクセスできないように見えることです。Eclipse と Windows 7 を使用しています。Translate jar ファイルを作成するために行った手順は次のとおりです。
- 翻訳プロジェクトを右クリック
- 書き出す
- 選択された実行可能な Jar ファイル
- 辞書を選択 - 起動構成として辞書
- エクスポート先として Dictionary\Translate.jar に入力
- [完了] をクリックしてから、プロセス ランタイムの使用を試みました。
現在、両方のプログラムの疑似コードしかありませんが、翻訳プログラムを呼び出す方法を見つけることに集中しています。
Dictionary.java
public class Dictionary {
public static void main(String [] args){
/******************
* Dictionary Program
* Will translate and return a foreign word back
* to the Translate program that this Program is calling.
* It will look up the English word. The Dictionary will use
* Elvish as the foreign language that is being translated.
* Should be able to translate 15 english words.
*/
/**********************************************************
/* External Module code calls Translate and gets output
*from module
/*********************************************************/
/* try
{
// Run a java app in a separate system process
Process proc = Runtime.getRuntime().exec("java -jar Translate.jar");
// Then retreive the process output
InputStream in = proc.getInputStream();
InputStream err= proc.getErrorStream();
BufferedReader reader = new BufferedReader(new InputStreamReader(proc.getInputStream()));
String EngWord = reader.readLine(); //EngWord is the variable sent from the Translate program
while ( (EngWord = reader.readLine()) != null)
do //Pseudo-code of (If, Else Statements provided below)
/**********************************************************************
* Pseudo-code
**********************************************************************/
String EngWord = "Should be a variable that the Translate Program is passing that is the english word";
String foreignWord = "A variable created by this Diction program that will be sent back to the Translate program";
if (EngWord == "dog") {
foreignWord = "elvish equivalent";
} else if (EngWord == "cat") {
foreignWord = "cat in elvish";
} else if (EngWord == "tree"){
foreignWord = "tree in elven";
} else {
EngWord = "nothing? something that can end the loop well";
// I guess this is where the loop must terminate
}
//Must find a way to return the foreignWord back to Translate
/*
} catch (Throwable e){
e.printStackTrace();
}
*/
}
}
Translate.java
public class Translate {
/**************************
* Translate program will pass the Dictionary program
* an English word. When the Dictionary program translate and returns an Elvish word
* This program will print out the English word and its translation into a file
*
*/
public static void main(String [] args) {
//Must find a way to pass the english word to Dictionary
String EngWord = "This is the variable being sent to the Dictionary program...use as parameter?";
//Must use some type of Writer class in order to write the output of both the EngWord and foreignWord
//into an Output file
String foreignWord = "THis is the variable being sent back from the Dictionary program";
//perhaps use runtime before this so Translate can retreive foreignWord from Dictionary?
//Some type of algorithm that will write both the foreignWord and Engword onto an output file.
//Prints (Writes) out to "output.txt"
}
}
そのような量の支援を受けることが許可されていない場合、この要求を投稿することが許可されている他の Web サイトを誰か教えてもらえますか?