Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class Schachbrett {
- public static void main(String[] args) {
- // SANITY CHECKS
- if (args.length != 1) {
- System.out.println("Usage: java Schachbrett {number}");
- return;
- }
- int size;
- try {
- size = Integer.parseInt(args[0]);
- } catch (NumberFormatException nfe) {
- System.out.println("Please enter a valid number");
- return;
- }
- if (size <= 0) {
- System.out.println("Please enter a number above 0");
- return;
- }
- // DRAWING
- boolean isBlack = true;
- for(int x = 0; x < size; x++) {
- for(int y = 0; y < size; y++) {
- System.out.print(isBlack ? "*" : " ");
- isBlack = !isBlack;
- }
- System.out.print("\n");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement