haze man 0 Newbie Poster

Hi guys I have already posted code to do with a solar system but this is my second go at it to make it better and more clean but i am have trouble making it actually print out the result in turtle. Could some one please help me? I think it is to do with the main, i dont know if i should be calling the turtle there or else where?
Thanks in advance for the help
Haze

import math
import turtle

class Planet:
    def __init__(self, name, rad, mass, dist, color, velX, velY):
        self.name = name
        self.rad = rad
        self.mass = mass
        self.dist = dist
        self.x = dist
        self.y = 0
        self.color = color

        self.pturtle = turtle.Turtle()

        self.pturtle.color(self.color)
        self.pturtle.shape('circle')

        self.pturtle.up()
        self.pturtle.goto(self.x, self.y)
        self.pturtle.down()

        self.velx = velX
        self.vely = velY

    def moveTo(self, newx, newy):
        self.x = newx
        self.y = newy
        sel.pturtle.goto(newx, newy)

    def getXVel(self):
        return self.velx

    def getYVel(self):
        return self.vely

    def setXVel(self):
        self.velx = newx

    def setYVel(sefl):
        self.vely = newy

    def getXPos(self):
        return self.x

    def getYPos(self):
        return self.y

    def __str__(self):
        return self.name

    def getName(self):
        return self.name

    def getRadius(self):
        return self.rad

    def getMass(self):
        return self.mass

    def getDist(self):
        return self.dist

    def getVolume(self):
        v = 4.0/3 * math.pi * self.rad**3
        return v

    def getSurfaceArea(self):
        sa = 4.0 * math.pi * self.rad**2
        return sa

    def getDensity(self):
        d = self.mass / self.getVolume()
        return d


class Sun:
    def __init__(self, name, rad, mass, temp):
        self.name = name
        self.rad = rad
        self.mass = mass
        self.temp= temp
        self.x = 0
        self.y = 0

        self.sturtle = turtle.Turtle()
        self.sturtle.shape('circle')
        self.sturtle.color('yellow')

    def getXPos(self):
        return self.x

    def getYPos(self):
        return self.y

    def getMass(self):
        return self.mass

    def getRadius(self):
        return self.rad

    def getTemperature(self):
        return self.temp

    def getVolume(self):
        v = 4.0/3 * math.pi * self.rad**3
        return v

    def getSurfaceArea(self):
        sa = 4.0 * math.pi * self.rad**2
        return sa

    def getDensity(self):
        d = self.mass / self.getVolume()
        return d

    def __str__(self):
        return self.name

class SolarSystem:
    def __init__(self, width, height):
        self.thesun = None
        self.planets = []
        self.ssturtle = turtle.Turtle()
        self.ssturtle.hideturtle()       

    def addSun(self, asun):
        self.thesun = asun

    def addPlanet(self, aplanet):
        self.planets.append(aplanet)

    def showPlanets(self):
        for aplanet in self.planets:
            print(aplanet)

    def movePlanets(self):
        G = 0.1
        dt = .001

        for p in self.planets:
            p.moveTo(p.getXPos() + dt * p.getXVel(),
                     p.getYPos() + dt * p.getYVel())

            rx = self.thesun.getXPos() - p.getXPos()
            ry = self.thesun.getYPos() - p.getYPos()
            r = math.sqrt(rx ** 2 + ry ** 2)

            accx = G * self.thesun.getMass() * ry / r ** 3
            accy = G * self.thesun.getMass() * ry / r ** 3

            p.setXVel(p.getXVel() + dt * accx)
            p.setYVel(p.getYVel() + dt * accy)


def main():


    ss = SolarSystem(2, 2)

    sun = Sun('SUN', 5000, 10, 5800)
    ss.addSun(sun)

    m = Planet('MERCURY', 19.5, 1000, .25, 0, 2, 'blue')
    ss.addPlanet(m)

    m = Planet('EARTH', 47.5, 5000, 0.3, 0, 2.0, 'green')
    ss.addPlanet(m)

    m = Planet('MARS', 50, 9000, 0.5, 0, 1.63, 'red')
    ss.addPlanet(m)

    m = Planet('JUPITER', 100, 49000, 0.7, 0, 1, 'black')
    ss.addPlanet(m)

    numTimePeriods = 2000
    for amove in range(numTimePeriods):
        ss.movePlanets()
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.