Lesson_05.04 - 05.04 Classes and Methods Name: Mishka Allam...

This preview shows page 1 - 2 out of 4 pages.

05.04 Classes and MethodsName: Mishka AllamThis assignment has three parts.Part One: Design the programWrite a program to define a Superhero class, set attributes and call the methods. Use thefollowing guidelines to write your program:1.Look over the code that starts the Superhero class. You may use this code as a startingpoint. Come up withtwoadditional attributes andonemethod to add to the class. Becreative! Some attributes could be a motto, villain, strength, weakness, or alter ego. Anaction might be saveWorld() or transformHero().class Superhero:# Superhero class represents the facts related to a superhero.def __init__(self, name = "", strengthPts = 0):# Create a new Superhero with a name and other attributes.self.name = nameself.strengthPts = strengthPtsdef addStrengthPts(self, points):# Adds points to the superhero's strength.self.strengthPts = self.strengthPts + points2.Update the class by including at least two new attributes and one new method.

Upload your study docs or become a

Course Hero member to access this document

Upload your study docs or become a

Course Hero member to access this document

End of preview. Want to read all 4 pages?

Upload your study docs or become a

Course Hero member to access this document

Term
Fall
Professor
N/A
Tags
Mishka Allam

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture