Code Monkey home page Code Monkey logo

s10-edu's People

Watchers

 avatar  avatar  avatar

s10-edu's Issues

Both => and : hash syntaxes are used in the project

In some places you use the Ruby 1.9 key: value syntax, in others the "old" :key => value syntax (Guardfile, Rakefile, game_spec.rb).

Just for the sake of picky consistency it might be worth using only one of those syntaxes.

Game#check_win mixes winner calculation and result strings building

Game#check_win does 2 things:

  1. find the winner
  2. build the strings that announce the result to the player

Maybe it could be renamed and simplified in something like:

def get_winner(opponent_hand, my_hand)
  case opponent_hand
  when my_hand then :draw
  when BEATS[my_hand] then :me
  else :you
  end
end

And move the result string building in the format_output method?

bin/rps can't quit

Currently quitting a game is not possible. Let's refactor bin/rps to allow quitting.

#!/usr/bin/env ruby

require_relative '../lib/rps'

game = Rps::Game.new
loop do
  print "Your turn. Choose one of [r, p, s] or q to quit: "
  action = gets.strip.to_sym
  case action
  when :r, :p, :s
    puts game.turn(action)
  when :q
    puts game.statistics
    exit
  else
    puts "Invalid hand!"
  end
end

method definitions should include parens

instead of writing this:

def foo bar, baz
  # ...
end

It is more idiomatic to write

def foo(bar, baz)
  # ...
end

There isn't an absolute consensus in the community, but the latter is much, much more widely accepted. For this reason, we ask that students use the latter style for MU related projects. (NOTE: This and similar points are covered by the MU Style Guide, which we expect you to be familiar with)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.