Error Message and Instructions for Ellens Alien Game (Issue 2992) (#3058)
Fenced the import of new_aliens_collection() function to throw custom error. Changed instructions to clarify that new_aliens_collection() is meant to be *outside* the Alien() class. Changed stub file to add a TODO around creating new_aliens_collection() explicitly outsied the Alien() class.
This commit is contained in:
@@ -108,16 +108,17 @@ For example:
|
||||
2
|
||||
```
|
||||
|
||||
## 7. Object Creation
|
||||
## 7. Creating a List of Aliens
|
||||
|
||||
Ellen loves what you've done so far, but she has one more favor to ask.
|
||||
She would like a standalone function to create a `list` of alien objects, given a list of positions (as `tuples`).
|
||||
She would like a standalone (_outside the `Alien()` class_) function that creates a `list` of `Alien()` objects, given a list of positions (as `tuples`).
|
||||
|
||||
For example:
|
||||
|
||||
```python
|
||||
>>> alien_start_positions = [(4, 7), (-1, 0)]
|
||||
>>> aliens = new_aliens_collection(alien_start_positions)
|
||||
...
|
||||
>>> for alien in aliens:
|
||||
print(alien.x_coordinate, alien.y_coordinate)
|
||||
(4, 7)
|
||||
|
||||
@@ -20,3 +20,6 @@ class Alien:
|
||||
"""
|
||||
|
||||
pass
|
||||
|
||||
|
||||
#TODO: create the new_aliens_collection() function below to call your Alien class with a list of coordinates.
|
||||
|
||||
@@ -1,12 +1,17 @@
|
||||
import unittest
|
||||
import pytest
|
||||
|
||||
from classes import new_aliens_collection
|
||||
|
||||
try:
|
||||
from classes import new_aliens_collection
|
||||
except ImportError as err:
|
||||
raise ImportError("We tried to import the new_aliens_collection() function, "
|
||||
"but could not find it. Did you remember to create it?") from err
|
||||
|
||||
try:
|
||||
from classes import Alien
|
||||
except ImportError as err:
|
||||
raise ImportError("We tried to import the 'Alien' class, but could not find it. "
|
||||
raise ImportError("We tried to import the 'Alien' class from the classes.py file, but could not find it. "
|
||||
"Did you remember to create it?") from err
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user