5.04 Classes and Methods.rtf - Name: Raelin Gao 05.04...

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

The preview shows page 1 - 2 out of 5 pages.
Name: Raelin Gao05.04 Classes and MethodsThis 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. Be creative!Some attributes could be a motto, villain, strength, weakness, or alter ego. An action might besaveWorld() or transformHero().class Superhero:# Superhero class represents the facts related to asuperhero.def __init__(self, name = "", strengthPts = 0):# Create a new Superhero with a name and otherattributesself.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.3.In the main() method, create your superhero. Be sure to assign values to its attributesand call its methods.4.Create output that describes your superhero in a story fashion or a series of events.

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 5 pages?

Upload your study docs or become a

Course Hero member to access this document

Term
Fall
Professor
N/A
Tags
Subroutine, Raelin Gao

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture