Skip to content

Instantly share code, notes, and snippets.

View tarynsauer's full-sized avatar

Taryn Sauer tarynsauer

  • Madison, WI
View GitHub Profile
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 {
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);
public abstract class AbstractHumanMove {
public abstract String getNextMove();
}
public class CLIHumanMove extends AbstractHumanMove {
private Board board;
public CLIHumanMove(Board board) {
this.board = board;
}
@Override
public String getNextMove() {
UI ui = new UI();
public class GameSettings {
private UI ui;
private Board board;
private int boardSize;
private String playerOne;
private String playerTwo;
private String playerFirstMove;
private AbstractHumanMove humanMoveType;
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();
require './app/helpers'
include ApplicantHelpers
get '/' do
erb :index
end
get '/applicants/new' do
@applicant = Applicant.new
erb :new_applicant
require './init'
module ApplicantHelpers
def month_day_year
"%m/%d/%Y"
end
def format_date(date)
return nil if date.nil?
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
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)