Day 20 NuCamp — OOP — Classes


The purpose of a class is to create an object

simple object creation

max_hp = 4000 is a CLASS ATTRIBUTE // is attached to the class itself.

Storing object in a variable (similar to calling a function)

Class and Instance Attributes and Constructor Methods

`Changing class attribute — which changes both variables
now hp is at 5000

Instance attributes | Constructor Method (Above code commented out)

“Class is like an object factory”

“Constructor method is what initializes each object created in the factory.”

Only run through parameters that will require arguments to manipulate. Self refers to object being referenced.
These are the arguments that will be ran through. Only two parameters because “self” will be referenced by python as the object.

Lines 17–19

(arguments passed in (“Aaron”, 1200) and (“Irene”, 1300) )

Line 22 -23

Line 25–26

Line 29–30

Notice the change in hp and score with player 1



Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store