Understanding Classes and Developing Classes
From GeoMod
So for homework this weekend the mad scientist Dr. Urbano, crazy guy from Trinidad that he is, decided that we need to understand how to construct a class.
For the project, he wanted us to design a car for our example, because a car is the best way to understand because cars have characteristics! The first thing to do is understand is when you develop the class, you have to define everything involved in the class. Like that of a car, you have to pick the kind, color, accessories, wheel type, number of doors..., you get the picture? So anyway, to begin you have to tell the cpu that you are going to make a class, you do this by saying class. Like this
class Stonecar:
Stonecar refers to what I am making and what its called, I'm making the Flintstone's car!
Next you tell the cpu every aspect of the car, ex body, wheels, steering wheel, all of that, for this I did it like this.
self.Stonecar=frame()
self.lchassis=box(frame=self.Stonecar, pos= (0,0,0),length = 5.25, height = 1, width = 0.25, color=color.magenta)
self.rchassis=box(frame=self.Stonecar, pos=(0,0,-4),length = 5.25, height = 1, width = 0.25, color=color.magenta)
self.rearwheel= cylinder(frame=self.Stonecar, pos=(2.5,0,-4), axis=(0,0,4), radius=1,color=(0.8, 0.8, 0.8))
self.frontwheel=cylinder(frame=self.Stonecar, pos=(-2.5,0,-4), axis=(0,0,4), radius=1,color=(0.8, 0.8, 0.8))
self.back=box(frame=self.Stonecar, pos=(2.5,2,-2), length=0.5, height = 4, width=3.9)
self.rightsidesupport=cylinder(frame=self.Stonecar, pos=(2.5,0,-4), axis=(0,4,0), radius=0.1, color=color.magenta)
self.leftsidesupport=cylinder(frame=self.Stonecar, pos=(2.5,0,0), axis=(0,4,0), radius=0.1, color=color.magenta)
self.topleftsupport=cylinder(frame=self.Stonecar, pos=(-1.4,4,0), axis=(4,0,0), radius=0.1, color=color.magenta)
self.toprightsupport=cylinder(frame=self.Stonecar, pos=(-1.4,4,-4), axis=(4,0,0), radius=0.1, color=color.magenta)
self.roof=box(frame=self.Stonecar, pos=(0.75,4,-2), length=4, height = 0.5, width=3.9)
self.rearwindow=box(frame=self.Stonecar, pos=(2.5,3,-2), length=.51, height = 1, width=2, color=color.black)
self.frontsupport=cylinder(frame=self.Stonecar, pos=(-1.3,4,-4), axis=(0,0,4), radius=0.1, color=color.magenta)
self.stearingcolumn=cylinder(frame=self.Stonecar, pos=(-1.5,0,-1), axis=(.5,.5,0), radius=0.1, color=color.magenta)
self.stearingwheel=cylinder (frame=self.Stonecar, pos=(-1,.55,-1), axis=(.1,.1,0),radius=.5, color=color.magenta)
self.seat=box(frame=self.Stonecar, pos=(1,0,-2), length=1, height = 0.125, width=4, color=color.magenta)
self.seatback=box(frame=self.Stonecar, pos=(1.5,0.5,-2), length=0.2, height =1, width=4, color=color.magenta)
self.dash=box(frame=self.Stonecar, pos=(-1.5,0.25,-2), length=0.2, height =1, width=4, color=color.magenta)
although, the thing you write in before this is to tell the computer that you are going to define the car and you want the cpu to create it after that. Also you have to follow it with self, bc any attribute you wish to change within the class can be easily referred back to as self.XXXXXXX. Get it, it looks like this.
def __init__(self):
You guys get the idea where I'm going. Since this is a class, you won't get any image if you run it, to get that image to run you have to start a new program!! So open up another python editor and tell it your going to want to see a picture and you want to get it from here! like this
from visual import *
from Stonecar import *
got it now go and do it punks!
I have set the guiness book of world record for idiotic dribble written on this cpu!
by the way, my car looks like this.
oh well doesnt work for me sorry.

