question.rb
solution.rb
playground.rb
1 require_relative "../physics" 2 3 question :the_resistor_on_a_ten_volt_battery do 4 kind :numerical 5 describes "A battery of emf %{emf} and internal resistance %{internal} is connected to a resistor. If the current " \ 6 "in the circuit is %{current}, %{resistance}, in ohms?" 7 given emf: "10 V" 8 given internal: "3 Ω" 9 given current: "0.5 A" 10 asks resistance: "what is the resistance of the resistor" 11 end
1 require_relative "../questions/the_resistor_on_a_ten_volt_battery" 2 require_relative "../science/current_electricity/ohms_law" 3 4 solve :the_resistor_on_a_ten_volt_battery , using: OhmsLaw do 5 objects :battery , :resistor , :circuit 6 7 take emf: circuit . voltage 8 take internal: battery . resistance 9 take current: circuit . current 10 11 deduce_from "connected to a resistor" , circuit . resistance => battery . resistance + resistor . resistance 12 13 resistance = resistor . resistance 14 answer resistance :, in: "Ω" , figures: 2 15 16 conclusion "The emf drives the current through the resistor and the battery's own resistance in a row, so " \ 17 "the two resistances together are the emf over the current." 18 end
1 require_relative "../solutions/the_resistor_on_a_ten_volt_battery" 2 3 play_with :the_resistor_on_a_ten_volt_battery do 4 title "The Resistor on a Ten Volt Battery" 5 end