Saint Louis University |
Computer Science 1300/5001
|
Computer Science Department |
Ensure that you adhere to the policies on academic integrity.
In a moment, we propose an implementation for a Radio class. For this problem, please do not focus on whether or not this is an accurate model for the semantics of a radio. Instead, our primary concern is that there are five critical mistakes with the implementation that lead to explicit errors.
You are to identify these five errors and for each:
Our implementation can be download electronically (code here), if you wish to experiment, or is displayed as follows (line numbers only for reference).
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
class Radio: def init(self): self._powerOn = False self._volume = 5 self._station = 90.7 self._presets = [ 90.7, 92.3, 94.7, 98.1, 105.7, 107.7 ] def togglePower(self): self._powerOn = not self._powerOn def setPreset(self, ind): self._presets[ind] = _station def gotoPreset(self, ind): self._station = self._presets[self._ind] def increaseVolume(self): self._volume = self._volume + 1 def decreaseVolume(self): self._volume = self._volume - 1 def increaseStation(self) self._station = self._station + .2 def decreaseStation(self): self._station = self._station - .2 |