緑色の部分がコメントです。まずはコメントを手がかりに全体像を俯瞰して下さい。
/* 「授業表」の定義 */
//入出力関連パッケージの利用を宣言する
import java.io.*;
public class ClassTable implements Serializable{
int no; // 属性1・時限
String subject; // 属性2・科目名
String room; // 属性3・教室名
/* メソッド1・属性の値を表示する */
public void showData (){
System.out.print("時限:");
System.out.println(no); // 「時限」の値を表示して改行
System.out.print("科目名:");
System.out.println(subject); // 「科目名」の値を表示して改行
System.out.print("教室名:");
System.out.println(room); // 「教室名」の値を表示して改行
}
/* メソッド2・属性の値を入力する */
public void inputData( BufferedReader reader )throws Exception{
try{
no = Integer.parseInt(reader.readLine());//「時限」の値を入力する
subject = reader.readLine(); //「科目名」の値を入力する
room = reader.readLine(); //「教室名」の値を入力する
}//エラーが発生したらエラーメッセージを示しプログラムを終了する
catch(Exception e){System.out.println("エラーが発生したのでプログラムを終了します");}
}
}
|
リンク: <講座1・その2(4)> |--------------------------|--------------------------| <サーバ用プログラム> <クライアント用プログラム> <時間割を定義するプログラム>