0504 Classes and Methods (1).pdf - 05.04 Classes and...

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

05.04 Classes and MethodsName:This assignment has three parts.Part One: Design the programWrite a program to define a Superhero class, set attributes and call the methods. Use the following guidelinesto write your program:1.Look over the code that starts the Superhero class. You may use this code as a starting point. Comeup withtwoadditional attributes andonemethod to add to the class. Be creative! Some attributescould be a motto, villain, strength, weakness, or alter ego. An action might be saveWorld() ortransformHero().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 + pointsUpdate the class by including at least two new attributes and one new method.In themain()method, create your superhero. Be sure to assign values to its attributes and call its methods.

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
Wanda Duchein
Tags
English language films, Ghost, Ghost Hunters, ghost hunter

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture