Question
Battery Model We want to design a program to manage battery models. (a) Define a type, BatteryModel, that represents a battery model, that is made
Battery Model We want to design a program to manage battery models. (a) Define a type, BatteryModel, that represents a battery model, that is made of the known voltage , the amount of energy it is capable of storing, and the energy it is currently storing (in joules). (b) Define a function PowerDevice that takes as arguments: a current of an electrical device (amps), a battery of type BatteryModel, and the time the device is to be powered by the battery (seconds), and determines whether the battery's energy reserve is adequate to power the device. If so, the function updates its reserve by subtracting the energy consumed and returns the value 1. Otherwise it returns the value 0 and leaves the energy reserve unchanged. (c) Define a function MaxTime that takes as arguments: a current of an electrical device and a battery of type BatteryModel, and returns the number of seconds this battery can operate the device before it is fully discharged. This function may not modify the energy reserve.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started