Created
August 31, 2012 18:15
-
-
Save kmandreza/3556822 to your computer and use it in GitHub Desktop.
8.31.12 SpaceShip class
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Object Oriented Design, Simon Allardice from lynda.com | |
#Class: SpaceShip | |
#Attributes: +public name: String | |
# -private shieldstrength: Integer | |
#Operations: +fire( ): String | |
# -reduce shields (Integer) | |
#Notes: 1. Public Class Spaceship | |
# 2. Attributes are expressed as instance variables, which are variables that belong to an instance of a class. What this means is that any object created within this class will have their own copy of these variables <--I NEED A VISUAL OF THIS BADLY | |
# 3. +Public or -Private refers to the visibility level of the features we are coding up. | |
class Spaceship | |
#instance variables | |
@name | |
@shieldstrength | |
#methods | |
def fire | |
return "Boom!" | |
end | |
def reduce_shields(amount) | |
shield_strength -= amount | |
end | |
end | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
should be: