Skip to main content
replaced http://codereview.stackexchange.com/ with https://codereview.stackexchange.com/
Source Link

As @Hoscho250@Hoscho250 pointed out in a comment, this doesn't do anything:

else if(size == 0) {
        
}

you say that you could have just used an else, but that's not fixing anything. You can just leave this code out. Since you're neither printing anything nor raising an error, you can ignore any case where size is less than 1.

public static void xo(int size) {
    
    if (size > 1) {
        int count = 0;
        for(int i = 1; i <= size; i++) {          
            for(int j = 1; j <= size; j++) {
                if((i == j) || (size - j - count == 0)) {
                    System.out.print("x");    
                } else {
                    System.out.print("o");
                }
            }
            count++;
            System.out.println();
        }
          
    } else if(size == 1) {
        System.out.println("x");
    }
}

As @Hoscho250 pointed out in a comment, this doesn't do anything:

else if(size == 0) {
        
}

you say that you could have just used an else, but that's not fixing anything. You can just leave this code out. Since you're neither printing anything nor raising an error, you can ignore any case where size is less than 1.

public static void xo(int size) {
    
    if (size > 1) {
        int count = 0;
        for(int i = 1; i <= size; i++) {          
            for(int j = 1; j <= size; j++) {
                if((i == j) || (size - j - count == 0)) {
                    System.out.print("x");    
                } else {
                    System.out.print("o");
                }
            }
            count++;
            System.out.println();
        }
          
    } else if(size == 1) {
        System.out.println("x");
    }
}

As @Hoscho250 pointed out in a comment, this doesn't do anything:

else if(size == 0) {
        
}

you say that you could have just used an else, but that's not fixing anything. You can just leave this code out. Since you're neither printing anything nor raising an error, you can ignore any case where size is less than 1.

public static void xo(int size) {
    
    if (size > 1) {
        int count = 0;
        for(int i = 1; i <= size; i++) {          
            for(int j = 1; j <= size; j++) {
                if((i == j) || (size - j - count == 0)) {
                    System.out.print("x");    
                } else {
                    System.out.print("o");
                }
            }
            count++;
            System.out.println();
        }
          
    } else if(size == 1) {
        System.out.println("x");
    }
}
Source Link
SuperBiasedMan
  • 13.1k
  • 5
  • 36
  • 62

As @Hoscho250 pointed out in a comment, this doesn't do anything:

else if(size == 0) {
        
}

you say that you could have just used an else, but that's not fixing anything. You can just leave this code out. Since you're neither printing anything nor raising an error, you can ignore any case where size is less than 1.

public static void xo(int size) {
    
    if (size > 1) {
        int count = 0;
        for(int i = 1; i <= size; i++) {          
            for(int j = 1; j <= size; j++) {
                if((i == j) || (size - j - count == 0)) {
                    System.out.print("x");    
                } else {
                    System.out.print("o");
                }
            }
            count++;
            System.out.println();
        }
          
    } else if(size == 1) {
        System.out.println("x");
    }
}