Advertisement
Guest User

Dame

a guest
Apr 27th, 2018
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.09 KB | None | 0 0
  1. public class DameAlissa {
  2.  
  3.  
  4. public static void main (String[] args) {
  5.  
  6.  
  7. Out.print ("Wie gross soll das Spielfeld Dame sein? Für 8x8 gib 8, für 10x10 gib 10, für 12x12 gib 12 ein:");
  8.  
  9. int n;
  10.  
  11. n = In.readInt();
  12.  
  13. while (n!=8 && n!=10 && n!=12){
  14.  
  15. Out.println ("Die Eingabe ist leider ungültig. Bitte beachte dass wenn du ein Feld welches 8x8 gross sein soll eine 8 eingegeben werden sollte. Für 10x10 entsprechend 10 und für 12x12 eine 12. ");
  16.  
  17. n = In.readInt();
  18.  
  19. }
  20.  
  21. Grid.create(n, n);
  22.  
  23.  
  24.  
  25. for (int column = 0; column < n; column++){
  26.  
  27. for (int row = 0; row < n; row++){
  28.  
  29. if (((column + row) % 2 )== 0)
  30.  
  31. Grid.paintFloor(row, column, Grid.YELLOW);
  32.  
  33.  
  34.  
  35. }
  36.  
  37. }
  38.  
  39.  
  40. for (int row = 0; row < 3; row++){
  41.  
  42. for (int column = 0; column < n; column++){
  43.  
  44. if (((column + row) % 2 )== 0)
  45.  
  46. Grid.placeItem(row, column , 'o');
  47.  
  48.  
  49. }
  50.  
  51. }
  52.  
  53.  
  54. for (int row = n-3; row < n; row++){
  55.  
  56. for (int column = 0; column < n; column++){
  57.  
  58. if (((column + row) % 2 )== 0)
  59.  
  60. Grid.placeItem(row, column , '*');
  61.  
  62.  
  63. }
  64.  
  65. }
  66.  
  67.  
  68. }
  69.  
  70.  
  71. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement