Advertisement
mikhail_dvorkin

NimConsoleView

Feb 27th, 2017
418
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.54 KB | None | 0 0
  1. package me.dvorkin;
  2.  
  3. import java.util.Arrays;
  4. import java.util.Scanner;
  5.  
  6. public class NimConsoleView {
  7.     NimModel model;
  8.     Scanner in = new Scanner(System.in);
  9.  
  10.     public NimConsoleView(NimModel model) {
  11.         this.model = model;
  12.     }
  13.  
  14.     public int[] interact() {
  15.         System.out.println("Field: " +
  16.                 Arrays.toString(model.getField()));
  17.         int player = model.whoMoves() ? 1 : 2;
  18.         System.out.println("Player " + player + ", make your move:");
  19.         int index = in.nextInt() - 1;
  20.         int amount = in.nextInt();
  21.         return new int[]{index, amount};
  22.     }
  23. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement