IT代考 ‘name’: ‘Problem 10’,

‘name’: ‘Problem 10’,
‘points’: 3,
‘suites’: [
‘cases’: [

Copyright By PowCoder代写 加微信 powcoder

‘answer’: ’30acf56ec75cb7d016a52156b35675d1′,
‘choices’: [
If the insect is not waterproof, its health is reduced to 0.
Otherwise, nothing happens.
“The insect’s health is reduced to 0.”,
‘Nothing happens.’,
‘The insect goes for a swim.’
‘hidden’: False,
‘locked’: True,
‘multiline’: False,
‘question’: ‘What happens when an insect is added to a Water Place?’
‘answer’: ‘0d0ba9307acaa82d9ec51399603a21a3’,
‘choices’: [
‘class, all ants of a subclass should either be waterproof or not’,
‘class, all ants should be waterproof’,
‘instance, the is_waterproof attribute depends on the amount of health a given ant has left’,
‘instance, the is_waterproof attribute depends on the given place of an ant’
‘hidden’: False,
‘locked’: True,
‘multiline’: False,
‘question’: ‘What type of attribute should “is_waterproof” be?’
‘answer’: ‘eeb478cf9b1eaff08a9196f6459c49e9’,
‘choices’: [
‘reduce_health, in the Insect class’,
‘remove_insect, in the Place class’,
‘sting, in the Bee class’,
‘remove_ant, in the GameState class’
‘hidden’: False,
‘locked’: True,
‘multiline’: False,
‘question’: r”””
What method deals damage to an Insect and removes it from its place
if its health reaches 0?
‘scored’: False,
‘type’: ‘concept’
‘cases’: [
‘code’: r”””
>>> # Testing water with Ants
>>> test_water = Water(‘Water Test1’)
>>> ant = HarvesterAnt()
>>> test_water.add_insect(ant)
>>> (ant.health, test_water.ant is None)
>>> ant = Ant()
>>> test_water.add_insect(ant)
>>> (ant.health, test_water.ant is None)
>>> ant = ThrowerAnt()
>>> test_water.add_insect(ant)
>>> (ant.health, test_water.ant is None)
‘hidden’: False,
‘locked’: False,
‘multiline’: False
‘code’: r”””
>>> # Testing water with soggy (non-waterproof) bees
>>> test_bee = Bee(1000000)
>>> test_bee.is_waterproof = False # Make Bee non-waterproof
>>> test_water = Water(‘Water Test2’)
>>> test_water.add_insect(test_bee)
>>> test_bee.health
40031e7755cbca1da159a160d30dbc21
>>> test_water.bees
d950d537d593b816b0182abc333e83fb
‘hidden’: False,
‘locked’: True,
‘multiline’: False
‘code’: r”””
>>> # Testing water with waterproof bees
>>> test_bee = Bee(1)
>>> test_water = Water(‘Water Test3’)
>>> test_water.add_insect(test_bee)
>>> test_bee.health
10d7626438082950badf2b6216f9b0a8
>>> test_bee in test_water.bees
154afc22815a37701b5fa71e532da526
‘hidden’: False,
‘locked’: True,
‘multiline’: False
‘code’: r”””
>>> # test proper call to death callback
>>> original_death_callback = Insect.death_callback
>>> Insect.death_callback = lambda x: print(“insect died”)
>>> place = Water(‘Water Test4’)
>>> soggy_bee = Bee(1)
>>> soggy_bee.is_waterproof = False
>>> place.add_insect(soggy_bee)
insect died
>>> place.add_insect(Bee(1))
>>> place.add_insect(ThrowerAnt())
insect died
>>> Insect.death_callback = original_death_callback
‘hidden’: False,
‘locked’: False,
‘multiline’: False
‘scored’: True,
‘setup’: r”””
>>> from ants import *
>>> from ants_plans import *
>>> beehive, layout = Hive(make_test_assault_plan()), dry_layout
>>> dimensions = (1, 9)
>>> gamestate = GameState(None, beehive, ant_types(), layout, dimensions)
‘teardown’: ”,
‘type’: ‘doctest’
‘cases’: [
‘code’: r”””
>>> # Testing water inheritance
>>> old_add_insect = Place.add_insect
>>> def new_add_insect(self, insect):
… print(“called add_insect”)
… old_add_insect(self, insect)
>>> Place.add_insect = new_add_insect
>>> test_bee = Bee(1)
>>> test_water = Water(‘Water Test4’)
>>> test_water.add_insect(test_bee) # if this fails you probably didn’t call `add_insect`
called add_insect
>>> Place.add_insect = old_add_insect
‘hidden’: False,
‘locked’: False,
‘multiline’: False
‘scored’: True,
‘setup’: r”””
>>> from ants import *
>>> from ants_plans import *
>>> beehive, layout = Hive(make_test_assault_plan()), dry_layout
>>> dimensions = (1, 9)
>>> gamestate = GameState(None, beehive, ant_types(), layout, dimensions)
>>> old_add_insect = Place.add_insect
‘teardown’: r”””
>>> Place.add_insect = old_add_insect
‘type’: ‘doctest’

程序代写 CS代考 加微信: powcoder QQ: 1823890830 Email: powcoder@163.com