This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package tictactoe; | |
| import java.io.IOException; | |
| import static tictactoe.TictactoeConstants.O_MARKER; | |
| import static tictactoe.TictactoeConstants.X_MARKER; | |
| public class GameRunner { | |
| public static void main(String[] args) throws IOException { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public String getMoveByType(String playerType) { | |
| if (playerType.equals(HUMAN_PLAYER)) { | |
| UI ui = new UI(); | |
| ui.setBoard(board); | |
| return ui.getNextMove(); | |
| } else if (playerType.equals(EASY_COMPUTER)) { | |
| return board.getRandomCell(); | |
| } else { | |
| AI ai = new AI(currentPlayer()); | |
| int cellID = ai.getAIMove(board); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public abstract class AbstractHumanMove { | |
| public abstract String getNextMove(); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public class CLIHumanMove extends AbstractHumanMove { | |
| private Board board; | |
| public CLIHumanMove(Board board) { | |
| this.board = board; | |
| } | |
| @Override | |
| public String getNextMove() { | |
| UI ui = new UI(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public class GameSettings { | |
| private UI ui; | |
| private Board board; | |
| private int boardSize; | |
| private String playerOne; | |
| private String playerTwo; | |
| private String playerFirstMove; | |
| private AbstractHumanMove humanMoveType; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public class Game { | |
| private Board board; | |
| private String playerOne; | |
| private String playerTwo; | |
| private String playerFirstMove; | |
| private AbstractHumanMove humanMoveType; | |
| public Game(GameSettings params) { | |
| this.playerOne = params.getPlayerOne(); | |
| this.playerTwo = params.getPlayerTwo(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| require './app/helpers' | |
| include ApplicantHelpers | |
| get '/' do | |
| erb :index | |
| end | |
| get '/applicants/new' do | |
| @applicant = Applicant.new | |
| erb :new_applicant |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| require './init' | |
| module ApplicantHelpers | |
| def month_day_year | |
| "%m/%d/%Y" | |
| end | |
| def format_date(date) | |
| return nil if date.nil? |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| post '/applicants' do | |
| @applicants = Applicant.paginate(:page => params[:page], :per_page => 10) | |
| if params["status"] == "all" | |
| redirect "/applicants" | |
| elsif params["status"] == "initial_reply_on" | |
| @applicants = Applicant.all(:conditions => {:initial_reply_on => nil, :completed_ttt_on => nil, :reviewed_on => nil, :begin_refactoring_on => nil, :resubmitted_ttt_on => nil}) | |
| erb :applicants | |
| elsif params["status"] == "ttt_challenge_sent" | |
| @applicants = Applicant.all(:conditions => {:initial_reply_on.not => nil, :completed_ttt_on => nil, :reviewed_on => nil, :begin_refactoring_on => nil, :resubmitted_ttt_on => nil}) | |
| erb :applicants |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| describe "filling in fields" do | |
| after :each do | |
| Applicant.all.destroy! | |
| end | |
| it "fills in date field" do | |
| visit "/applicants/#{test_applicant.id}" | |
| fill_in 'initial_reply_on', with: "01/25/2014" | |
| click_button('Update profile') | |
| applicant = Applicant.get(test_applicant.id) |