このブログを検索

2019年8月31日土曜日

アホ男子のための 割り算 問題 学習プログラム(作成中)⑧

アホ男子 の為の 割り算学習プログラム。
 
 とりあえず、ボタンに「正解」等を表示するのではなく、
 新たに Label を作り そこに 表示させる事にした。

 今回は その位置決めのみ。

 
 
⭐️新たに Label を作成。

//◯5回出題させてみよう
//×表示の不具合を治す。
//新しくLabelを作る。
//
import java.awt.*;
import java.awt.event.*;
class Display1{
    public static void main(String[] args){
        MyWindow mw = new MyWindow();
    }
}

class MyWindow extends Frame implements ActionListener{
    Label la1, la2;
    Button btn1, btn2;
    int moto; //割られる数値です。
    int waru; //割る数値です。
    int ans; //答え
    int amari; //答え(あまり)
    static int count = 1;
    static int seikai;
    MyWindow(){
        setTitle("問題集");
        setSize(640, 400);
        setLayout(null); //レイアウトの解除
        btn1 = new Button("◯");
        btn2 = new Button("×");
        btn1.setBounds(100, 300, 150, 80);
        btn2.setBounds(400, 300, 150, 80);
        btn1.addActionListener(this);
        btn2.addActionListener(this);
        add(btn1);
        add(btn2);
        la1 = new Label( questions() );
        la1.setFont(new Font("Serif", Font.PLAIN, 34));
        la1.setAlignment(Label.CENTER);
        la1.setBackground(Color.LIGHT_GRAY); //Label 1 背景色
        la1.setForeground(Color.BLACK);  //Label 文字色
        la1.setBounds(100, 100, 450, 50);
        add(la1);
        la2 = new Label("テ ス ト");
        //la2 = setFont(new Font("Serif", Font.PLAIN, 34));
        la2.setAlignment(Label.CENTER);
        la2.setBackground(Color.LIGHT_GRAY); //Label 2 背景色
        la2.setForeground(Color.BLACK);  //Label 2 文字色
        la2.setBounds(150, 180, 350, 50);
        add(la2);
        setVisible(true);
        addWindowListener( new WinListener() );
    }
    
    public String questions(){
        waru = (int)(Math.random()*29)+2; //割る数値(2〜30)
        ans = (int)(Math.random()*9)+1; //答え(1〜9)
        amari = (int)(Math.random()*(waru-1))+1; //あまりの数値(1〜割る数値−1)
        moto = waru * ans + amari; //割られる数値
        System.out.println(moto + " ÷ " + waru + " = " + ans + " ... " + amari);//験算用
        btn1.setLabel("◯");
        btn2.setLabel("×");
        int ran1 = (int)(Math.random()*2); //間違いの発生 確率50% ただし 変数に0を加算する事もある。
        if(ran1 == 0){
            int ran2 = (int)(Math.random()*3);
            if(ran2 == 0){
                int falseAmari = (int)(Math.random()*3);
                falseAmari -= 1;
                amari = amari + falseAmari; // あまりに -1,0,1 を加算
            }
            else{
                int falsewaru = (int)(Math.random()*2);
                ans = ans + falsewaru; // 商に 0,1 を加算
            }
        }
            
        return moto + " ÷ " + waru + " = " + ans + " ... " + amari;
    }
    
    public boolean judgment(){
        return moto/waru==ans && moto%waru==amari; //答えと 余りの判定。booleanにて返す。
    }
    
    
    public void actionPerformed(ActionEvent e){
        if(e.getSource() == btn1) {
            if(judgment() == true){
                btn1.setLabel("正解 !");
                countCalculation();
            }
            else{
                btn1.setLabel("違っているよ !");
                countCalculation();
            }
        }
        if(e.getSource() == btn2) {
            if(judgment() == false){
                btn2.setLabel("正解 !");
                countCalculation();
            }
            else{
                btn2.setLabel("違っているよ !");
                countCalculation();
            }
        }
    }
    
    public void countCalculation(){
        try { Thread.sleep(2000); } catch (InterruptedException e) {} // 2秒間だけ処理を止める
        System.out.println(count + "回目"); //試験用
        count++;
        if(count <= 5){  //5回で終了。
            la1.setText( questions() ); //ラベルの表示の書き換え questions() メソッドへ
        }
        else{
            System.out.println("お疲れ様でした。");
        }
    }
}

class WinListener extends WindowAdapter{
    public void windowClosing(WindowEvent e){System.exit(0);}

}


今後、Labelに 「正解」等を表示させよう。


今日の教訓


 今日はあまり勉強できなかったな。
 こんな日もあるさ。

2019年8月30日金曜日

Progate Java学習コースの復習(学習コース2 総合課題)

半月ほど前、
 Progateという Web上でプログラミングを学べる学習サイト があります。
 とりあえず、Javaコースは 一周出来ました。
 特に 抽象クラス・ポリモーフィズムの説明のスライドは
 本当に解りやすかった。
 
 Javaコースを一周した後、
 他の言語を勉強しようかと 考えました。
  大人気の Python
  挫折したまま 放置している Ruby
  みんな学習している JavaScript

 とりあえず、Javaをもう一度 やってみよう。

 その際の注意点。
 ・PCのテキストエディタを使用する。
 ・変数等の 命名は 解りやすいものにする。
 ・BufferedReader InputStreamReader を使用する。
 ・try〜catch文で 例外処理を行う。
 ・親クラス 子クラスを使用する。

 とりあえず、学習コース2 総合課題を やってみた。
 (そんなに 難しくないので すぐでけた)

 ここでは、プログラムは 載せません。

今日の教訓
 道場コース2 とかは 1日以上 かかるんだろうな〜 (白目)

2019年8月29日木曜日

アホ男子のための 割り算 問題 学習プログラム(作成中)⑦

 アホ男子 の為の 割り算学習プログラム。
 
 try { Thread.sleep(2000); } catch (InterruptedException e) {}
 上の文を使って 2秒 時間を止めて
 ボタンに「正解!」「まちがっているよ!」を
 表示させたい。

 しかし、ボタンに「正解」等を表示する前に、
 時間が止まってしまうんだな。

 

 どの位置に Thread.sleep() を持ってきても 「◯」「×」しか表示されない。
 (実際には 表示されるんだけど、すぐに上書きされてしまう。)
 (画像は ◯ × の 書き換えを // で無効にしたもの)

 忘備録として、
 このプログラムは 3つのclassに分かれている。
 (将来的には 問題表示と 正誤判定の部分を別クラスにしたい)
 "main"起動クラス、"MyWindow"動作開始、"WinListener"終了

 MyWindow クラスのメソッドの流れは、
 
 MyWindow() "AWTの表示"
     ↓
 questions() "MyWindow() 内にて呼び出される 問題の作成 Stringにして返す"
     ↓
 actionPerformed(ActionEvent e) "ボタンの判定"
     ↓
 judgment() "actionPerformed(ActionEvent e)  内にて呼び出される
       クラス変数を元に booleanにして返す"
 countCalculation() "actionPerformed(ActionEvent e) 内にて呼び出される
       クラス変数を元に 出題回数をカウント"
     ↓
 questions()

 この countCalculation() 内で Thread.sleep() を使い
 「正解!」等を 2秒間表示したいんだけど 何故か
 ここで止められない。

⭐️2秒 止まるは止まるけれど。。。


//◯間違いを作ろう(あまり)
//◯間違いを作ろう(商)
//◯5回出題させてみよう
//表示の不具合を治す。
import java.awt.*;
import java.awt.event.*;
class Times4{
    public static void main(String[] args){
        MyWindow mw = new MyWindow();
    }
}

class MyWindow extends Frame implements ActionListener{
    Label la;
    Button btn1, btn2;
    int moto; //割られる数値です。
    int waru; //割る数値です。
    int ans; //答え
    int amari; //答え(あまり)
    static int count = 1;
    static int seikai;
    MyWindow(){
        setTitle("問題集");
        setSize(640, 400);
        setLayout(null); //レイアウトの解除
        btn1 = new Button("◯");
        btn2 = new Button("×");
        btn1.setBounds(100, 300, 150, 80);
        btn2.setBounds(400, 300, 150, 80);
        btn1.addActionListener(this);
        btn2.addActionListener(this);
        add(btn1);
        add(btn2);
        la = new Label( questions() );
        la.setFont(new Font("Serif", Font.PLAIN, 34));
        la.setAlignment(Label.CENTER);
        la.setBackground(Color.LIGHT_GRAY); //Label 背景色
        la.setForeground(Color.BLACK);  //Label 文字色
        la.setBounds(100, 100, 450, 50);
        add(la);
        setVisible(true);
        addWindowListener( new WinListener() );
    }
    
    public String questions(){
        waru = (int)(Math.random()*29)+2; //割る数値(2〜30)
        ans = (int)(Math.random()*9)+1; //答え(1〜9)
        amari = (int)(Math.random()*(waru-1))+1; //あまりの数値(1〜割る数値−1)
        moto = waru * ans + amari; //割られる数値
        System.out.println(moto + " ÷ " + waru + " = " + ans + " ... " + amari);//験算用
        btn1.setLabel("◯");
        btn2.setLabel("×");
        int ran1 = (int)(Math.random()*2); //間違いの発生 確率50% ただし 変数に0を加算する事もある。
        if(ran1 == 0){
            int ran2 = (int)(Math.random()*3);
            if(ran2 == 0){
                int falseAmari = (int)(Math.random()*3);
                falseAmari -= 1;
                amari = amari + falseAmari; // あまりに -1,0,1 を加算
            }
            else{
                int falsewaru = (int)(Math.random()*2);
                ans = ans + falsewaru; // 商に 0,1 を加算
            }
        }
            
        return moto + " ÷ " + waru + " = " + ans + " ... " + amari;
    }
    
    public boolean judgment(){
        return moto/waru==ans && moto%waru==amari; //答えと 余りの判定。booleanにて返す。
    }
    
    
    public void actionPerformed(ActionEvent e){
        if(e.getSource() == btn1) {
            if(judgment() == true){
                btn1.setLabel("正解 !");
                countCalculation();
            }
            else{
                btn1.setLabel("違っているよ !");
                countCalculation();
            }
        }
        if(e.getSource() == btn2) {
            if(judgment() == false){
                btn2.setLabel("正解 !");
                countCalculation();
            }
            else{
                btn2.setLabel("違っているよ !");
                countCalculation();
            }
        }
    }
    
    public void countCalculation(){
        try { Thread.sleep(2000); } catch (InterruptedException e) {} // 2秒間だけ処理を止める
        System.out.println(count + "回目"); //試験用
        count++;
        if(count <= 5){  //5回で終了。
            la.setText( questions() ); //ラベルの表示の書き換え questions() メソッドへ
        }
        else{
            System.out.println("お疲れ様でした。");
        }
    }
}

class WinListener extends WindowAdapter{
    public void windowClosing(WindowEvent e){System.exit(0);}

}


今後、修正したい部分。
 あれこれ、原因を考えるより ラベルをもう1つ作り、
 そこに「正解!」等を表示した方が早いのではないか。。。


今日の教訓
 あれこれ 壁にぶち当たってるな〜

2019年8月28日水曜日

時間を止めたい!

アホ男子 の為の 割り算学習プログラム。
 sleep() メソッドを使って カッコよく時間を止めたい、
 スレッドを もう一度 勉強しなくては〜〜
 もっと楽に 時間を止められねいものか。。。

 ネットでポチポチ。
 Thread.sleep という方法があるらしい。
 これだと、Threadクラスを拡張したクラスを作成せずに自由に時間を
 止めることが出来るそうだ。
 
 


⭐️Dio様 時間よ止まれ The World !

class Main {
    public static void main(String[] args) {
        System.out.println("the World 時間よ止まれ!!");
        try { Thread.sleep(5000); } catch (InterruptedException e) {}
        System.out.println("そして時間は動き出す。ドシャャャャャ〜");
    }

}

割り算プログラムで、試してみよう。


今日の教訓
 オイラも Dio様になれたよ。

2019年8月27日火曜日

アホ男子のための 割り算 問題 学習プログラム(作成中)⑥

 アホ男子 の為の 割り算学習プログラム。
 とりあえず、5回問題を回答させて、
 最後に 結果を出したい。 

 クラス変数 static int count = 1; (1 〜 5問 出題をする)
 でもって、if(count <= 5) MyWindow(); //5回で終了。
 
 失敗! エラー: シンボルを見つけられません
 
 ボケーっと 口を開けて ふらふら歩いている時、
 突如 気が付いた。
 ラベルを書き直したら 良いのではないかと!!

 わかった事。
 MyWindow() メソッドではなく、
 questions() メソッド で ラベルを書き換えれば良い。
 また、ラベルを書き換えるのは la.setText(  ); を使用する。



⭐️5回表示のプログラム

//◯次は 合否判定をしてみよう。メソッドを作る。System.out.println()にて出力
//◯Buttonに合否判定を反映
//◯間違いを作ろう(あまり)
//◯間違いを作ろう(商)
//5回出題させてみよう
import java.awt.*;
import java.awt.event.*;
class Times2{
    public static void main(String[] args){
        MyWindow mw = new MyWindow();
    }
}

class MyWindow extends Frame implements ActionListener{
    Label la;
    Button btn1, btn2;
    int moto; //割られる数値です。
    int waru; //割る数値です。
    int ans; //答え
    int amari; //答え(あまり)
    static int count = 1;
    static int seikai;
    MyWindow(){
        setTitle("問題集");
        setSize(640, 400);
        setLayout(null); //レイアウトの解除
        btn1 = new Button("◯");
        btn2 = new Button("×");
        btn1.setBounds(100, 300, 150, 80);
        btn2.setBounds(400, 300, 150, 80);
        btn1.addActionListener(this);
        btn2.addActionListener(this);
        add(btn1);
        add(btn2);
        la = new Label( questions() );
        la.setFont(new Font("Serif", Font.PLAIN, 34));
        la.setAlignment(Label.CENTER);
        la.setBackground(Color.LIGHT_GRAY); //Label 背景色
        la.setForeground(Color.BLACK);  //Label 文字色
        la.setBounds(100, 100, 450, 50);
        add(la);
        setVisible(true);
        addWindowListener( new WinListener() );
    }
    
    public String questions(){
        waru = (int)(Math.random()*29)+2; //割る数値(2〜30)
        ans = (int)(Math.random()*9)+1; //答え(1〜9)
        amari = (int)(Math.random()*(waru-1))+1; //あまりの数値(1〜割る数値−1)
        moto = waru * ans + amari; //割られる数値
        System.out.println(moto + " ÷ " + waru + " = " + ans + " ... " + amari);//験算用
        
        int ran1 = (int)(Math.random()*2); //間違いの発生 確率50% ただし 変数に0を加算する事もある。
        if(ran1 == 0){
            int ran2 = (int)(Math.random()*3);
            if(ran2 == 0){
                int falseAmari = (int)(Math.random()*3);
                falseAmari -= 1;
                amari = amari + falseAmari; // あまりに -1,0,1 を加算
            }
            else{
                int falsewaru = (int)(Math.random()*2);
                ans = ans + falsewaru; // 商に 0,1 を加算
            }
        }
            
        return moto + " ÷ " + waru + " = " + ans + " ... " + amari;
    }
    
    public boolean judgment(){
        return moto/waru==ans && moto%waru==amari; //答えと 余りの判定。booleanにて返す。
    }
    
    
    public void actionPerformed(ActionEvent e){
        if(e.getSource() == btn1) {
            System.out.println("◯ を押しました" + judgment()); //験算用
            if(judgment() == true){
                btn1.setLabel("正解 !");
                countCalculation();
            }
            else{
                btn1.setLabel("違っているよ !");
                countCalculation();
            }
        }
        if(e.getSource() == btn2) {
            System.out.println("× を押しました" + judgment()); //験算用
            if(judgment() == false){
                btn2.setLabel("正解 !");
                countCalculation();
            }
            else{
                btn2.setLabel("違っているよ !");
                countCalculation();
            }
        }
    }
    
    public void countCalculation(){
        System.out.println(count + "回目でした。"); //試験用
        count++;
        //try{ sleep(2000); } catch(InterruptedException e) {} //2秒間処理を停止
        if(count <= 5){  //5回で終了。
            btn1.setLabel("◯");  //ボタンの表示の書き換え
            btn2.setLabel("×");  //ボタンの表示の書き換え
            la.setText( questions() ); //ラベルの表示の書き換え questions() メソッドへ
        }
        else{
            System.out.println("お疲れ様でした。");
        }
    }
}

class WinListener extends WindowAdapter{
    public void windowClosing(WindowEvent e){System.exit(0);}

}

今後、修正したい部分。
 ボタンの表示が「正解」「違っているよ!」から
 「◯」「×」 に戻そうとすると 「正解」等が表示されない。
 (実際には 表示しているけど 見えない。)
 sleep() メソッドを使って 処理を停止したいけど、
 うまく使えない。
 スレッドか〜〜〜!!


今日の教訓
 たまには ぼーっと歩いてみよう。

2019年8月26日月曜日

Java入門教室 Chapter10「図形を描こう」④

「Java入門教室」

 Chapter10「図形を描こう」
 でもって、ポチポチっと 色を変更させた後、
 残った重複部分を 入力専用のメソッドに置き換えてみた。


⭐️重複部分を 1つのメソッドに置き換えてみた。

// 改良点
// ◯重複部分を修正する。

// 注意事項 Colorクラスの変数により 色の設定ができる。
// 注意事項 返り値は Color。
// 注意事項 return で 色を返す時には "" は不要。
// 注意事項 return で返す時には switch 分の場合は break; は不要。
import java.awt.*;
import java.awt.event.*;
import java.io.*;

class Line2{
    public static void main(String[] args) throws IOException{
        MyWindow mw = new MyWindow();
    }
}

class MyWindow extends Frame{
    //フィールドの作成
    int startX;  // 始点X
    int startY;  // 始点Y
    int endX;    // 終点X
    int endY;    // 終点Y
    Color col;   // Colorクラスの変数
    
    MyWindow(){
        System.out.println("直線を引きます。始点と終点を入力して下さい。");
        startX = inputNum("始点 X点は? (20 ~ 380 までの数値で)  "); //引数を与えて input()メソッドを呼び出す。
        startY = inputNum("始点 Y点は? (20 ~ 380 までの数値で)  ");
        endX = inputNum("終点 X点は? (20 ~ 380 までの数値で)  ");
        endY = inputNum("終点 Y点は? (20 ~ 380 までの数値で)  ");
        col = inputCol("色は? 1)BLACK 2)BLUE 3)RED 4)GREEN  ");
        
        setTitle("図形を描く");
        setSize(400, 400);
        setVisible(true);
        addWindowListener(new WinListener());
        
    }
    public void paint(Graphics g){
        g.setColor( col );
        g.drawLine(startX, startY, endX, endY);
    }
    public static int inputNum(String txt){ //start end の数値の入力
        System.out.print(txt); //引数 txt の表示
        int num = input();
        if(num >= 20 && num <= 380){ //入力した数値が 20~380の範囲内であるのか確認
            return num;
        }
        else{
            System.out.println("範囲を超えている もしくは数値以外が入力された為、200を代入します。");
            return 200;
        }
    }
    
    public static Color inputCol(String txt){ //注意 返り値は Color
        System.out.print(txt); //引数 txt の表示
        int colorNum = input();
        if(colorNum == -9999){
            System.out.println("数値以外が入力されました。 1)BLACK 色に指定します。");
            colorNum = 1;
        }
        
        switch(colorNum){
            case 1:
                return Color.BLACK; // 注意””は不要!
            case 2:                 // 注意 break; は不要!
                return Color.BLUE;
            case 3:
                return Color.RED;
            case 4:
                return Color.GREEN;
            default:
                System.out.println("1~4 以外の数値が入力されました。1)BLACK 色に指定します。");
                return Color.BLACK;
        }
    }
    
    public static int input(){ //数値の入力のみのメソッド
        
        BufferedReader br =
         new BufferedReader(new InputStreamReader(System.in));
        String str = null;
        
        try{
            str = br.readLine();
        }catch(IOException e){
            System.out.println(e);
        }
        
        try{
            return Integer.parseInt(str);
        }
        catch(Exception e){
            return -9999;//数値以外の際 -9999 を返す。
        }
    }
}

class WinListener extends WindowAdapter{
    public void windowClosing(WindowEvent e){System.exit(0);}

}

 このプログラム、数値以外の入力の際 -9999 を返すことによって
 返し先のメソッドで 判断を委ねているのですが、
 この処理を もっとスマートにできないものか。。。

今日の教訓
 この本 もう一度 最初から 打ち直してみよう。

2019年8月25日日曜日

Java入門教室 Chapter10「図形を描こう」③

「Java入門教室」

Chapter10「図形を描こう」
 色を指定して 図形を描くプログラム。

 以前、線を引くプログラムを作った際、
 色を変更する 事が出来なかった (挫折!)
 
 ↓過去
 https://nerimagooglife.blogspot.com/2019/05/java-chapter10.html
 https://nerimagooglife.blogspot.com/2019/06/blog-post.html
 
 今回、この「Java入門j教室」をポチポチとPCを打ちながら
 読み進むうちに フィールドに Color col; という
 記述が。。。
 
 何でも Colorクラスで宣言した変数には
 Color.RED など を放り込む事が出来るらしい。
 
 でもって、ポチポチっと 色を変更させてみた。

 // 注意事項 Colorクラスの変数により 色の設定ができる。
 // 注意事項 返り値は Color。
 // 注意事項 return で 指定色を返す時には "" は不要。
 // 注意事項 return で返す時には switch 分の場合は break; は不要。 


  
⭐️前回のプログラムを 少し変えてみました。

// 改良点
// ◯例外処理を try~catch に統一しよう
// ◯インデントを直そう
// ◯色を変更出来る様にしよう
// 注意事項 Colorクラスの変数により 色の設定ができる。
// 注意事項 返り値は Color。
// 注意事項 return で 色を返す時には "" は不要。
// 注意事項 return で返す時には switch 分の場合は break; は不要。
import java.awt.*;
import java.awt.event.*;
import java.io.*;

class Line{
    public static void main(String[] args) throws IOException{
        MyWindow mw = new MyWindow();
    }
}

class MyWindow extends Frame{
    //フィールドの作成
    int startX;  // 始点X
    int startY;  // 始点Y
    int endX;    // 終点X
    int endY;    // 終点Y
    Color col;   // Colorクラスの変数
    
    MyWindow(){
        System.out.println("直線を引きます。始点と終点を入力して下さい。");
        startX = inputN("始点 X点は? (20 ~ 380 までの数値で)  "); //引数を与えて input()メソッドを呼び出す。
        startY = inputN("始点 Y点は? (20 ~ 380 までの数値で)  ");
        endX = inputN("終点 X点は? (20 ~ 380 までの数値で)  ");
        endY = inputN("終点 Y点は? (20 ~ 380 までの数値で)  ");
        col = inputC("色は? 1)BLACK 2)BLUE 3)RED 4)GREEN  ");
        
        setTitle("図形を描く");
        setSize(400, 400);
        setVisible(true);
        addWindowListener(new WinListener());
        
    }
    public void paint(Graphics g){
        g.setColor( col );
        g.drawLine(startX, startY, endX, endY);
    }
    public static int inputN(String txt){ //start end の数値の入力
        System.out.print(txt); //引数 txt の表示
        
        BufferedReader br =
         new BufferedReader(new InputStreamReader(System.in));
        int n; //try~catch外でも 変数nを使用したい為
        String str = null;
        
        try{
            str = br.readLine();
        }catch(IOException e){
            System.out.println(e);
        }
        
        try{                             //数値以外が入力された際の例外処理
            n = Integer.parseInt(str);
        }
        catch(Exception e){
            System.out.println("数値以外が入力されました。"); //数値以外の際 200をnに代入
            n = 200;
        }
        
        int num = 200;           //初期値は200
        if(n >= 20 && n <= 380) num = n; //入力した数値が 20~380の範囲内であるのか確認
        return num;
    }
    
    public static Color inputC(String txt){ //注意 返り値は Color
        System.out.print(txt); //引数 txt の表示
        
        BufferedReader br =
         new BufferedReader(new InputStreamReader(System.in));
        int n;
        String str = null;
        
        try{
            str = br.readLine();
        }catch(IOException e){
            System.out.println(e);
        }
        
        try{
            n = Integer.parseInt(str);
        }
        catch(Exception e){
            System.out.println("数値以外が入力されました。 1)BLACK 色に指定します。");
            n = 1;
        }
        
        switch(n){
            case 1:
                return Color.BLACK; // 注意””は不要!
            case 2:                 // 注意 break; は不要!
                return Color.BLUE;
            case 3:
                return Color.RED;
            case 4:
                return Color.GREEN;
            default:
                System.out.println("1~4 以外の数値が入力されました。1)BLACK 色に指定します。");
                return Color.BLACK;
        }
    }
}

class WinListener extends WindowAdapter{
    public void windowClosing(WindowEvent e){System.exit(0);}

}

今日の教訓
 重複部分があるのでスッキリさせよう。。。