def problem1(self, s): """Test the Backpack class. 10 points.""" # Test the constructor (2 points) b1 = Backpack("Teacher", "silver") b2 = s.Backpack("Student", "green") points = 2 # Test put() (6 points). for item in range(5): b1.put(item); b2.put(item) points += self._eqTest(b1.contents, b2.contents, "Backpack.put() failed to update Backpack.contents correctly") print("\nCorrect output:\t"),; b1.put(5) print("Student output:\t"),; b2.put(5) points += self._grade(1, 'Backpack.put() failed to print "No Room!"') points += self._eqTest(b1.contents, b2.contents, "Backpack.put() failed to update Backpack.contents correctly") b1 = Backpack("Teacher", "silver", 1) b2 = s.Backpack("Student", "green", 1) b1.put(100); b2.put(100) print("\nCorrect output:\t"),; b1.put(200) print("Student output:\t"),; b2.put(200) points += self._grade(1, 'Backpack.put() failed to print "No Room!"') points += 2*self._eqTest(b1.contents, b2.contents, "Backpack.put() failed to update Backpack.contents correctly") # Test dump() (2 points) b1.dump(); b2.dump() points += 2*self._eqTest(b1.contents, b2.contents, "Backpack.dump() failed to empty contents") return points