From essays to dissertations, we have experts for all of your assignments!

dot
  • 1.provide your instructions
  • 2.choose an expert in your field
  • 3.track the order progress

Python programming

I need help to write this following code in python.

1. DynamicEntity (class) – Inherits from Entity
DynamicEntity is an abstract class which provides base functionality for special types of Entities that are dynamic (e.g. can move from their original position).

set_position(self, new_position: tuple[int, int]) -> None

Updates the DynamicEntitys position to new_position, assuming it is a valid position.

Examples
>>> dynamic_entity = DynamicEntity((1, 1))
>>> dynamic_entity.get_position()
(1, 1)
>>> dynamic_entity.set_position((2, 3))
>>> dynamic_entity.get_position()
(2, 3)
>>> dynamic_entity.get_id()
‘DE’
>>> str(dynamic_entity)
‘DE’
>>> dynamic_entity
DynamicEntity((2, 3))

2. Item – Inherits from Entity
Subclass of Entity which provides base functionality for all items in the game.
apply(self, player: Player) -> None
Applies the items effect, if any, to the given player.

Examples
>>> player = Player((2, 3))
>>> item = Item((4, 5))
>>> item.apply(player)
Traceback (most recent call last):

NotImplementedError
>>> item.get_position()
(4, 5)
>>> item.get_name()
‘Item’
>>> item.get_id()
‘I’
>>> str(item)
‘I’
>>> item
Item((4, 5))

The Entity class example

Examples
>>> entity = Entity((2, 3))
>>> entity.get_position()
(2, 3)
>>> entity.get_name()
‘Entity’
>>> entity.get_id()
‘E’
>>> str(entity)
‘E’
>>> entity
Entity((2, 3))

You can leave a response, or trackback from your own site.

Leave a Reply

Powered by WordPress | Designed by: Premium WordPress Themes | Thanks to Themes Gallery, Bromoney and Wordpress Themes