Rubyの宿題教えてくだ ..
[2ch|▼Menu]
310:デフォルトの名無しさん
09/01/05 10:20:05
# つづき
 def start
  @reset.state = :disabled
  @start.configure(:text=>'確認',:command=>proc{check})
  @cells.each {|line| line.each {|cell| cell.state = :normal ; cell.value = '' }}
  @cells[0][0].focus
  @starttime = Time.now
 end
 def check
  @endtime = Time.now
  @cells.each_with_index do |line,r|
   line.each_with_index do |cell,c|
    y,x = @row[r].text.to_i,@column[c].text.to_i
    case @op.text
    when '+' then answer = y + x
    when '-' then answer = y - x
    when '*' then answer = y * x
    end
    ( cell.focus ; Tk.bell ; return ) if answer != cell.value.to_i
   end
  end
  time = @endtime - @starttime
  TkDialog.new(@root,:buttons=>[:OK],:message=>"#{time.to_i}秒かかりました")
  init
 end
 def random(min,max) ; rand(max - min + 1) + min ; end
 def run ; init ; Tk.mainloop ; end
end
# $test = true
Drill100.new(Tk.root).run


次ページ
続きを表示
1を表示
最新レス表示
スレッドの検索
類似スレ一覧
話題のニュース
おまかせリスト
▼オプションを表示
暇つぶし2ch

5379日前に更新/99 KB
担当:undef