Flag%20question%3A%20Question%202%0AQuestion%202%0A4%20pts%0AMatch%20each%20example%20wit…
- User
Flag%20question%3A%20Question%202%0AQuestion%202%0A4%20pts%0AMatch%20each%20example%20with%20the%20best%20matching%20object%20oriented%20programming%20term%0AGroup%20of%20answer%20choices%0AA%20Player%20object%20having%20an%20ISprite%20object%20that%20it%20uses%20in%20its%20Draw%20method.%0A%0A%5B%20Choose%20%5D%0AComposition%0APolymorphism%0AInheritance%0AEncapsulation%0ASetting%20an%20enemy%20class'%20position%20fields%20to%20private%20so%20that%20other%20objects%20do%20not%20accidentally%20alter%20the%20position.%0A%0A%5B%20Choose%20%5D%0AComposition%0APolymorphism%0AInheritance%0AEncapsulation%0AHaving%20a%20TextureAtlasSprite%20class%20that%20multiple%20other%20sprite%20classes%20extend%20from.%0A%0A%5B%20Choose%20%5D%0AComposition%0APolymorphism%0AInheritance%0AEncapsulation%0AHaving%20a%20collection%20of%20type%20IGameObject%2C%20then%20running%20a%20foreach%20loop%20on%20that%20collection%20that%20only%20operates%20on%20IBlocks%0A%0A%5B%20Choose%20%5D%0AComposition%0APolymorphism%0AInheritance%0AEncapsulation
- Assistant
Here are the matches for each example with the best corresponding object-oriented programming term:
-
A Player object having an ISprite object that it uses in its Draw method.
- Answer: Composition
- Explanation: Composition refers to a "has-a" relationship where one class contains another class as a part, suggesting that the Player object is made up of (or contains) an ISprite object.
-
Setting an enemy class' position fields to private so that other objects do not accidentally alter the position.
- Answer: Encapsulation
-