Florida Southern Seal
CSC 2280: Intro Programming
(Fall 2024)

Syllabus

LMS

Teachers

Assignments
Assignments


Other Pages

Project 10:
Objective Reasoning


Assigned: Mon Nov 18 2024
Due: 11:59:00 PM on Tue Nov 19 2024
Team Size: 1
Language: Python
Out of: 13 points


In this project, you'll create a class and write functions that use objects.

Part 0, 2 points: Create a new class to model Pokemon.

Part 1, 0 points: You should now be able to create a Pokemon object like this:

pyro = Pokemon()
pyro.name = 'Flareon'
pyro.number = 136
pyro.types = ['Fire']
pyro.hit_points = 71
pyro.max_hp = 77
Use this to give your Pokemon class a meaningful docstring. Tester.

Part 2, 3 points: Add a new function, has_full_hp, which takes a Pokemon object as the parameter, and returns whether it is at full hit points.

>>> pyro = Pokemon()
>>> pyro.name = 'Flareon'
>>> pyro.number = 136
>>> pyro.types = ['Fire']
>>> pyro.hit_points = 71
>>> pyro.max_hp = 77
>>> has_full_hp(pyro)
False
>>> pyro.hit_points = 77
>>> has_full_hp(pyro)
True
Tester.

Part 3, 3 points: Add a new function, print_pokemon, which takes a Pokemon object as a parameter and prints out information about it:

>>> schiggy = Pokemon()
>>> schiggy.name = 'Squirtle'
>>> schiggy.number = 7
>>> schiggy.types = ['Water']
>>> schiggy.hit_points = 56
>>> schiggy.max_hp = 56
>>> print_pokemon(schiggy)
Pokemon: Squirtle (7) HP: 56/56
Tester.

Part 4, 5 points: Add a new function, spray_potion, which takes a Pokemon object as a parameter and adds 20 hit points (without going above their max). If a pokemon has zero hit points, this shouldn't heal it (because it needs to be revived first).

>>> schiggy = Pokemon()
>>> schiggy.name = 'Squirtle'
>>> schiggy.number = 7
>>> schiggy.types = ['Water']
>>> schiggy.hit_points = 20
>>> schiggy.max_hp = 56
>>> spray_potion(schiggy)
>>> schiggy.hit_points
40
>>> spray_potion(schiggy)
>>> schiggy.hit_points
56
>>> schiggy.hit_points = 0
>>> spray_potion(schiggy)
>>> schiggy.hit_points
0
Tester.

Submitting your Project:

Make sure all your code is in a file labelled with your user name (everything before the @ in your school email address) followed by _projects.py all in snake_case. (For example, my file name would be: kburke_projects.py.) It's very important to name your file correctly in order for me to grade it. Make sure your code runs, then upload it to the project on Canvas. (Don't submit code that doesn't run; you won't earn any points!) Your code should include solutions to all non-zero-point problems from Project 0 onwards. If there is already a file up on Canvas, delete that before uploading the new version or make sure your new file replaces that. (Sometimes Canvas adds a number after the file name. Don't worry about that, because it's something (freaking annoying) you don't have control of. I have a script that automatically deletes that.)