wicz / s10-edu Goto Github PK
View Code? Open in Web Editor NEWThis project forked from mendicant-original/s10-edu
This project forked from mendicant-original/s10-edu
From this note:
Some projects try to do the right thing by using namespaces, but end up doing so in a somewhat brittle way. The typical code smell starts in the entry point to the library, where a bare module is defined
So I think you should remove https://github.com/wicz/s10-edu/blob/fe84615fa789d4a55c005fbc8d70d5c5f698b319/lib/rps.rb#L4-5
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 does 2 things:
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?
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
For me
HANDS = %w{ r p s }.map(&:to_sym)
is simpler if written
HANDS = [:r, :p, :s]
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)
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.