ResolutionComparer.java :  » Game » infinitewars » main » Java Open Source

Java Open Source » Game » infinitewars 
infinitewars » main » ResolutionComparer.java
package main;

import java.util.Comparator;

public class ResolutionComparer implements Comparator<String> {
  
  @Override
  public int compare(String resA, String resB) {
    String[] modeA = resA.split("x");
    String[] modeB = resB.split("x");
    int widthA = Integer.valueOf(modeA[0]).intValue();
    int heightA = Integer.valueOf(modeA[1]).intValue();
    int widthB = Integer.valueOf(modeB[0]).intValue();
    int heightB = Integer.valueOf(modeB[1]).intValue();
    if(widthA != widthB) return (widthA > widthB) ?  1 : -1;
    if(heightA != heightB) return (heightA > heightB) ?  1 : -1;
    return 0;
  }
}
java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.