Symbianize Forum

Most of our features and services are available only to members, so we encourage you to login or register a new account. Registration is free, fast and simple. You only need to provide a valid email. Being a member you'll gain access to all member forums and features, post a message to ask question or provide answer, and share or find resources related to mobile phones, tablets, computers, game consoles, and multimedia.

All that and more, so what are you waiting for, click the register button and join us now! Ito ang website na ginawa ng pinoy para sa pinoy!

Change the values of x and y axis independently with each car? in Python

Status
Not open for further replies.

God love us

Amateur
Advanced Member
Messages
134
Reaction score
0
Points
26
how can i change the values of the xAxis and the yAxis because what I'm having as an output are only zeroes.

Code:
#I want to have a result like this:
    Car: Red       xAxis: 10 yAxis: 50
    Car: Yellow    xAxis: 20 yAxis: 40
    Car: Green     xAxis: 30 yAxis: 30
    Car: Blue      xAxis: 40 yAxis: 20
    Car: White     xAxis: 50 yAxis: 10

class Car():
    def __init__(self,color):
        self.color = color
        self.xAxis = 0
        self.yAxis = 0
    def moveUp(self):
        self.yAxis+=1
    def moveRight(self):
        self.xAxis+=1

CarColor = ['Red','Yellow','Green','Blue','White']
CarList = []
for eachColor in CarColor:
CarList.append(Car(eachColor))
for eachCar in CarList:
    print("Car:",eachCar.color,end=' ') 
    print("xAxis:",eachCar.xAxis,end=' ') 
    print("yAxis:",eachCar.yAxis,end='\n')
 
Status
Not open for further replies.
Back
Top Bottom