2017-04-05 152 views
0

有人可以幫我解決這個問題。有編譯錯誤$SwitchMap$uk$ac$aber$dcs$blockmotion$gui$DirectionInputMismatchException我該寫什麼呢?反編譯器代碼錯誤

以下是整個功能。如果有人能給我一個簡短的解釋讓我明白髮生了什麼,我會很感激。

private void setSlideNumber(String msg, Direction direction) { 

    boolean tryAgain = true; 

    do { 
     System.out.println(msg); 

     try { 
      int ime = Math.abs(this.in.nextInt()); 
      switch(null.$SwitchMap$uk$ac$aber$dcs$blockmotion$gui$Direction[direction.ordinal()]) { 
       case 1: 
        this.slideHorizontalLeftNum = -ime; 
        ((SlideTransformer)this.slideHorizontallyLeftTransformer).setAmount(this.slideHorizontalLeftNum); 
        break; 
       case 2: 
        this.slideHorizontalRightNum = ime; 
        ((SlideTransformer)this.slideHorizontallyRightTransformer).setAmount(this.slideHorizontalRightNum); 
        break; 
       case 3: 
        this.slideVerticalUpNum = -ime; 
        ((SlideTransformer)this.slideVerticallyUpTransformer).setAmount(this.slideVerticalUpNum); 
        break; 
       case 4: 
        this.slideVerticalDownNum = ime; 
        ((SlideTransformer)this.slideVerticallyDownTransformer).setAmount(this.slideVerticalDownNum); 
      } 

      tryAgain = false; 
     } catch (InputMismatchException var8) { 
      System.out.println("Please type a valid number"); 
     } finally { 
      this.in.nextLine(); 
     } 
    } while(tryAgain); 

} 

順便說一句,Direction是一個枚舉

,這是幻燈片變壓器

public abstract class SlideTransformer implements Transformer { 
    int amount; 

    public SlideTransformer(int amount) { 
     this.amount = amount; 
    } 

    public int getAmount() { 
     return this.amount; 
    } 

    public void setAmount(int amount) { 
     this.amount = amount; 
    } 
} 

現在枚舉方向的代碼類:

public enum Direction { 
    LEFT, 
    RIGHT, 
    UP, 
    DOWN; 

    private Direction() { 
    } 
} 
+2

什麼是nu $ SwitchMap $ uk $ ac $ aber $ dcs $ blockmotion $ gui $方向 – Arvindsinc2

+1

InputMismatchException的錯誤是什麼? –

+0

從哪裏得到'null。$ SwitchMap $ uk $ ac $ aber $ dcs $ blockmotion $ gui $ Direction [direction.ordinal()]'這個想法是否正確Java? –

回答

1

你奇怪的一段代碼來自一個類的反編譯。

switch是在Direction枚舉的序值進行,所以只需更換:

switch(null.$SwitchMap$uk$ac$aber$dcs$blockmotion$gui$Direction[direction.ordinal()]) 

switch(direction.ordinal()) 

請注意,我們通常switch直接在枚舉,並使用其不同的值,它更直接:

switch(direction){ 

    case LEFT :... 
    case RIGHT : ... 
    ... 

}