예제 #1
0
 def __init__(self, x, y, type, numOfVehicles, numOfLanes, vehicleSpeed, height):
     self.x = x
     self.y = y
     self.height = height
     self.cars = []
     self.numOfLanes = numOfLanes
     if type ==1: #lane of cars
         for i in range(numOfVehicles):
             if i%2 == 0:
                 if vehicleSpeed >= 0:
                     c = Car(x + i * 60, y + self.height/4, vehicleSpeed)
                 else:
                     c = Lorry(x + self.width - i * 70, y + self.height/4, vehicleSpeed)
             else:
                 if vehicleSpeed >= 0:
                     c = Car(x + i * 60, y + self.height/4, vehicleSpeed)
                 else:
                     c = Car(x + self.width - i * 60, y + self.height/4, vehicleSpeed)
             self.cars.append(c)
     if type ==2: #lane of lorrys
         for i in range(numOfVehicles):
             if i%2 == 0:
                 if vehicleSpeed >= 0:
                     c = Lorry(x + i * 70, y + self.height/4, vehicleSpeed)
                 else:
                     c = Lorry(x + self.width - i * 70, y + self.height/4, vehicleSpeed)
             else:
                 if vehicleSpeed >= 0:
                     c = Lorry(x + i * 70, y + self.height/4, vehicleSpeed)
                 else:
                     c = Lorry(x + self.width - i * 70, y + self.height/4, vehicleSpeed)
             self.cars.append(c)
예제 #2
0
    def __init__(self):
        self.car = Car()
        self.car.stop()

        self.map = Map((self.MapSize, self.MapSize), self.TileSize)
        self.pos = mul(self.map.sizeInMeters(), (0.5, ) * 2)
        self.dir = 0.0
예제 #3
0
def main():

	#car objects created with different cars
	
	c1 = Car.Car(2009, "Toyota")
	c2 = Car.Car(2012, "Ford")
	c3 = Car.Car(2015, "Honda")

	#String representation all 3 cars
	print("  MAKE    YEAR    SPEED")
	print(c1)
	print(c2)
	print(c3)


	print()

	#accelerate 5 times 
	print("Accelerating {0} {1}". format(c1.getYear(), c1.getMake()))
	for i in range(6):
		print("{0}".format(c1.getSpeed()), end=" ")
		if c1.getSpeed() < 22:
			c1.accelerate()

	print()
	print()
	#loop using applyBreak() 5 times
	print("Applying break to {0} {1}". format(c1.getYear(), c1.getMake()))
	for i in range(6):
		print("{0}".format(c1.getSpeed()), end=" ")
		c1.applyBreak()
예제 #4
0
def index(request, route):
    close_old_connections()
    if route == 'wxegisterSign':
        callBackDict = UserInfo.wxegisterSign(request)
    elif route == 'wxgetCarList':
        callBackDict = Car.wxgetCarList(request)
    elif route == 'wxAddCar':
        callBackDict = Car.wxAddCar(request)
    elif route == 'wxEditCar':
        callBackDict = Car.wxEditCar(request)
    elif route == 'getCarInfo':
        callBackDict = CheckGetInfo.getCarInfo(request)
    elif route == 'getGetTaskInfo':
        callBackDict = CheckGetInfo.getGetTaskInfo(request)
    elif route == 'getDoTaskInfo':
        callBackDict = CheckGetInfo.getDoTaskInfo(request)
    elif route == 'adminGetAllUsers':
        callBackDict = UserInfo.adminGetAllUsers(request)
    elif route == 'perfectUserInfo':
        callBackDict = UserInfo.perfectUserInfo(request)
    elif route == 'webSign':
        callBackDict = UserInfo.webSign(request)
    elif route == 'adminisEnabledUser':
        callBackDict = UserInfo.adminisEnabledUser(request)
    else:
        return HttpResponse("no found !!!")
    if callBackDict == None:
        callBackDict = {"code": -1, 'msg': '系统异常'}
    return HttpResponse(json.dumps(callBackDict))
 def test_car_wheels(self):
     man = Car('MAN', 'Truck', 'trailer')
     koenigsegg = Car('Koenigsegg', 'Agera R')
     self.assertEqual(
         [8, 4], [man.num_of_wheels, koenigsegg.num_of_wheels],
         msg=
         'The car shoud have four (4) wheels except its a type of trailer')
    def reproduce(self,cars):
        nextGenCars = []
        self.maxFitness = 0
        for i in range(0,np.size(cars)):
            if(cars[i].fitness > self.maxFitness):
                self.maxFitness = cars[i].fitness
                self.maxFitnessIndex = i
        neuralNetworkStructure = cars[0].neuralNetwork.neuralNetworkArchitecture
        if(self.maxFitnessIndex != -1):
            nextGenCars.append(Car.Car(cars[0].posInit,cars[0].sensors,neuralNetworkStructure))
            nextGenCars[0].neuralNetwork = NN.NNetwork(1,neuralNetworkStructure,[cars[self.maxFitnessIndex].neuralNetwork])
            nextGenCars[0].isBest = True

        else:
            nextGenCars.append(Car.Car(cars[0].posInit,cars[0].sensors,neuralNetworkStructure))
            nextGenCars[0].neuralNetwork = NN.NNetwork(1,neuralNetworkStructure,self.crossover(cars))
            self.mutate(nextGenCars[0])

        for i in range(1,np.size(cars)):
            nextGenCars.append(Car.Car(cars[0].posInit,cars[0].sensors,neuralNetworkStructure))
            
            nextGenCars[i].neuralNetwork = NN.NNetwork(1,neuralNetworkStructure,self.crossover(cars))
            self.mutate(nextGenCars[i])
        self.generation += 1
        return nextGenCars
예제 #7
0
    def __init__(self, x, y, type, numOfVehicles, vehicleSpeed, height):
        self.x = x
        self.y = y
        self.height = height
        self.cars = []
        self.carsSpeed = vehicleSpeed
        if type == 1:  #lane of cars
            for i in range(numOfVehicles):
                if vehicleSpeed >= 0:
                    c = Car(x + i * 50, y + height / 4, vehicleSpeed)
                    self.startX = x
                    #self.startY = y+10
                else:
                    c = Car(x + self.width - i * 50, y + height / 4,
                            vehicleSpeed)
                    self.startX = x + self.width
                    #self.startY = y + 10
                self.cars.append(c)

        if type == 2:  #lane of lorries
            for i in range(numOfVehicles):
                if vehicleSpeed >= 0:
                    c = Lorry(x + i * 70, y + height / 4, vehicleSpeed)
                    self.startX = x
                else:
                    c = Lorry(x + self.width - i * 70, y + height / 4,
                              vehicleSpeed)
                    self.startX = x + self.width
                self.cars.append(c)
예제 #8
0
	def __init__(self):
		self.car = Car(self.TRACK_LENGHT)
		self.road = Road()
		self.ambient = self.init_ambient() #lista de objetos que nao colidem com o carro
		self.obstacles = self.init_obstacles()
		self.angle = 50
		self.game_over = False
예제 #9
0
    def run(self):
        clock = pygame.time.Clock()
        screen = pygame.display.set_mode((self.width, self.height))
        screen1 = pygame.Surface((self.width    , self.height))
        pygame.display.set_caption(self.title)
        car1 = Car(self.width//2, self.height//2)
        pygame.mixer.music.load('engine.wav')
        pygame.mixer.music.play(-1)
        while(True):
            fps = 30
            clock.tick(fps)
            pygame.display.update()
            self.keyPressed(car1)
            car1.update()
            self.xOff = car1.x
            self.yOff = car1.y
            font = pygame.font.SysFont("comicsansms", 30)
            self.time += 1/30
            timerS = "LAP TIME : " + str(int(self.time))
            text = font.render(timerS, True, (0, 0, 0))
            
            #Checks for quitting
            for event in pygame.event.get():
                if event.type == pygame.QUIT:
                     pygame.quit();
                     sys.exit();

            screen.fill((0, 255, 0))
            self.redrawAll(screen, car1, text)
            
            pygame.display.flip()
            pygame.mixer.music.load('engine.wav')
            pygame.mixer.music.play(-1)
예제 #10
0
    def initialize(self):
        # Setup Background, game objects, and initial states
        win = GraphWin('App-Controlled Car', 800, 600)

        self.maze = Maze(win)
        self.maze.draw()

        self.car = Car(win)
        self.car.draw()

        self.isRunning = True

        # Setup Queues, Listeners, and off threads
        self.inputQueue = Queue(maxsize=0)

        #keyboardListener = KeyboardListener(self.inputQueue)
        #keyboardListener.start()

        joystickListener = JoystickListener("Web Joystick Listener",
                                            self.inputQueue)
        joystickListener.start()

        # Setup Game Loop
        self.run()

        # Pause and Close
        win.getMouse()
        win.close()
예제 #11
0
 def test_drive_car(self):
     man = Car('MAN', 'Truck', 'trailer')
     moving_man = man.drive(7)
     moving_man_instance = isinstance(moving_man, Car)
     moving_man_type = type(moving_man) is Car
     self.assertListEqual([True, True, man.speed],
                          [moving_man_instance, moving_man_type, moving_man.speed],
                          msg='The car drive function should return the instance of the Car class')
예제 #12
0
    def test_car_speed2(self):
        man = Car('Mercedes', 'SLR500')
        parked_speed = man.speed
        moving_speed = man.drive(3).speed

        self.assertListEqual([parked_speed, moving_speed],
                             [0, 1000],
                             msg='The Mercedes should have speed 0 km/h until you put `the pedal to the metal`')
예제 #13
0
    def test_car_speed(self):
        man = Car('MAN', 'Truck', 'trailer')
        parked_speed = man.speed
        moving_speed = man.drive(7).speed

        self.assertListEqual([parked_speed, moving_speed],
                             [0, 77],
                             msg='The Trailer should have speed 0 km/h until you put `the pedal to the metal`')
예제 #14
0
 def test_car_doors(self):
     opel = Car('Opel', 'Omega 3')
     porshe = Car('Porshe', '911 Turbo')
     self.assertListEqual([opel.num_of_doors,
                          porshe.num_of_doors,
                          Car('Koenigsegg', 'Agera R').num_of_doors],
                          [4, 2, 2],
                          msg='The car shoud have four (4) doors except its a Porshe or Koenigsegg')
예제 #15
0
class Slam:
    MapSize = 16
    TileSize = 0.25
    ScanAngle = math.pi / 3

    def __init__(self):
        self.car = Car()
        self.car.stop()

        self.map = Map((self.MapSize, self.MapSize), self.TileSize)
        self.pos = mul(self.map.sizeInMeters(), (0.5, ) * 2)
        self.dir = 0.0

    def scan(self):
        self.car.pointSonic()
        scans = self.car.scanSector(-self.ScanAngle, self.ScanAngle)
        for ang, dist in scans:
            delta = vecindir(self.dir + ang, dist)
            end = add(self.pos, delta)
            self.map.setLine(self.pos, end)

    def turn(self, tgt):
        to = sub(tgt, self.pos)
        a = normalize_angle(vecdir(to) - self.dir)
        self.car.turn(a)
        self.dir = normalize_angle(self.dir + a)

    def moveTo(self, tgt):
        self.turn(tgt)
        dist = vecdist(tgt, self.pos)
        self.car.move(dist)
        self.pos = tgt
예제 #16
0
def getData(dataFile, hoofdbrandstof):
    cars = []
    with open(dataFile, "rU") as csvfile:
        reader = csv.reader(csvfile, "SKV")
        reader.next()   # skip titles
        for row in reader:
            car = Car()
            car.fillAspects(row)
            if car.Hoofdbrandstof == hoofdbrandstof:
                cars.append(car)
    return cars
예제 #17
0
class main():
    def __init__(self):
        self.initialize()

    def initialize(self):
        # Setup Background, game objects, and initial states
        win = GraphWin('App-Controlled Car', 800, 600)

        self.maze = Maze(win)
        self.maze.draw()

        self.car = Car(win)
        self.car.draw()

        self.isRunning = True

        # Setup Queues, Listeners, and off threads
        self.inputQueue = Queue(maxsize=0)

        #keyboardListener = KeyboardListener(self.inputQueue)
        #keyboardListener.start()

        joystickListener = JoystickListener("Web Joystick Listener",
                                            self.inputQueue)
        joystickListener.start()

        # Setup Game Loop
        self.run()

        # Pause and Close
        win.getMouse()
        win.close()

    def run(self):
        # Game Loop
        while self.isRunning:
            # Process Events - Process inputs and other things
            self.processEvents()

            # Update - Update all objects that needs updating, ex position changes, physics
            #self.car.update(joystickInput)

            # Draw - Render things on screen
            self.car.move(self.inputQueue.get()['x'] * carSpeed,
                          self.inputQueue.get()['y'] * carSpeed)

            # Pause thread for framerate
            time.sleep(0.017)

    def processEvents(self):
        # Check if game is complete or not
        if self.car.carBody.getCenter().getX(
        ) > 580 and self.car.carBody.getCenter().getY() > 380:
            self.isRunning = False
예제 #18
0
 def spawn_cars(self, rate, r0, r1, r2, r3):
     if random.random() < r0:
         car_list.append(Car(575, -500, 0, SOUTH, 100, (92, 152, 249)))
         env.total_num_cars += 1
     if random.random() < r1:
         car_list.append(Car(1700, 425, 0, WEST, 100, (92, 152, 249)))
         env.total_num_cars += 1
     if random.random() < r2:
         car_list.append(Car(625, 1400, 0, NORTH, 100, (92, 152, 249)))
         env.total_num_cars += 1
     if random.random() < r3:
         car_list.append(Car(-500, 475, 0, EAST, 100, (92, 152, 249)))
         env.total_num_cars += 1
예제 #19
0
 def start(self):
     c = Car.Car()  # creating the Car object
     e = EventHandler.EventHandler(
         c
     )  # the event handler object is created. The Car object is passed as an argument
     c.setEventHandler(e)
     c.startCar()  # method in car class is invoked to start the car
def main():

    car_year_model = 0
    car_make = ""
    car_speed = 0

    car_year_model = input("Enter year model: ")
    car_make = input("Enter the make of car: ")
    car_speed = int(input("Enter the speed: "))

    car = Car.Car(car_year_model, car_make, car_speed)

    x = 0
    current_speed = 0

    print("\nYear Model: ", car.get_year_model())
    print("Make: ", car.get_make())

    for x in range(0, 4):
        current_speed += car.accelerate(car_speed)
        x += 1
        print("Current Speed: ", current_speed)

    x = 0

    for x in range(0, 4):
        current_speed -= car.brake(car_speed)
        x += 1
        print("Current Speed: ", current_speed)
예제 #21
0
def main():

    pl.figure(figsize=(8 * 1.1, 6 * 1.1))
    pl.axis('equal')
    pl.grid('on')
    pl.xlabel('x (meters)')
    pl.ylabel('y (meters)')
    pl.legend(fancybox=True, framealpha=0.5)
    pl.xlim([-20., 20.])
    pl.ylim([-20., 20.])

    start = (0.0, 0.0, 0.0)
    myCar = Car.Car(2.66, 1.5, -1.0, start, 5.5)
    myCar.visualize_as_center = False
    if os.path.isfile('cost_func.pickle'):
        with open('cost_func.pickle', 'rb') as handle:
            cost_func = pickle.load(handle)
    for current_cell in cost_func:
        current_pos = nonholonomic_cost_func.dist_2_cont(current_cell)
        # myCar.visualize(current_pos, 'c:')
        pl.plot(current_pos[0], current_pos[1], '+c', label='start')
        #
        # pl.pause(0.01)
    pl.show()
    print 'End.'
예제 #22
0
    def parsing(self, input):
        """
        Transform input string to board

        :param input: input board
        :type input: str
        :return: None
        """
        lines = list(map(lambda l: l.strip(), input.strip().split('\n')))
        self.height = len(lines)
        prev = '.'
        for i, line in enumerate(lines):
            width = len(line.replace('>', ''))
            if self.width == 0:
                self.width = width
            else:
                assert  self.width == width, "Check equality"
            for j, char in enumerate(line):
                if char == '.':
                    pass
                elif char == '>':
                    self.finish = (i, j)
                elif char not in self.cars:
                    self.cars[char] = Car(char, Position(i, j), 1)
                else:
                    self.cars[char].size += 1
                    self.cars[char].is_horizontal = (char == prev)
                prev = char
예제 #23
0
 def run(self):
     rbfn_parameter = [
         self.iteration_entry.get(),
         self.numberOfGroup_entry.get(),
         self.matingProbability_entry.get(),
         self.mutationProbability_entry.get(),
         self.numberOfHiddenLayerNeurons_entry.get()
     ]
     self.rbfn = RBFN.RBFN(rbfn_parameter, self.data)
     optimal_vector = self.rbfn.train()
     self.car = Car.Car(self.car_info, self.car_size, self.rbfn,
                        optimal_vector)
     is_arrived, wheel_degree_list, car_degree_list, car_loaction_list, distant_array = self.car.run(
     )
     if is_arrived:
         self.draw_arrived_track(car_degree_list, car_loaction_list)
         print("error times:", self.count_error)
         print("global_min_e:", self.rbfn.ga.global_min_e)
         print("optimal_vector:", optimal_vector)
         for i in range(len(wheel_degree_list)):
             print("wheel_degree_list[" + str(i) + "]:" +
                   str(wheel_degree_list[i]) + ", car_degree_list[" +
                   str(i) + "]:" + str(car_degree_list[i]) +
                   ", self.car_x:" + str(car_loaction_list[i][0]) +
                   " self.car_y:" + str(car_loaction_list[i][1]) +
                   ", front_distant:" + str(distant_array[i][0]) +
                   " right_distant:" + str(distant_array[i][1]) +
                   " left_distant:" + str(distant_array[i][2]))
         print('\n\n')
         self.count_error = 0
     else:
         print(self.count_error)
         self.count_error += 1
         self.run()
예제 #24
0
def car_predicting(model, year_car, color,karkerd):

    Car.CAR_data_fetching()
    dbconnector_C = mysql.connector.connect(host="127.0.0.1",
                                          user="******" % mysq_useranem,
                                          password="******" % mysql_password,
                                          database="H_C",
                                          table="car_info"
                                          )


    my_cursor_C = dbconnector_C.cursor()

    
    X = []
    Y = [] #price of car

    my_cursor_C.execute("SELECT model, year_car, color, karkard FROM car_info;")
    res1 = my_cursor_C.fetchall()
    for row1 in res1:
        X.append(row1)
    my_cursor_C.execute("SELECT price FROM car_info;")
    res2 = my_cursor_C.fetchall()
    for row2 in res2:
        Y.append(row2)
    person1 = [[model, year_car, color, karkerd]]
    carpred = tree.DecisionTreeClassifier()
    carpred = carpred.fit(X, Y)
    answer1 = carpred.predict(person1)
    dbconnector_C.commit()
    dbconnector_C.close()

    my_cursor_C.close()
    return answer1
예제 #25
0
    def apply(self):
        self.scr.delete('1.0', tk.END)
        
        car_var1 = self.field1_variable.get()
        car_var2 = self.field2_variable.get()
        car_var3 = self.field3_variable.get()
        car_var4 = self.field4_variable.get()
        
        if len(car_var1) < 3:
            self.scr.insert(tk.INSERT, 'Warning:\tInvalid make / make not found\n')
        if len(car_var2) < 1:
            self.scr.insert(tk.INSERT, 'Warning:\tInvalid model / model not found\n')
        if len(car_var3) < 4:
            self.scr.insert(tk.INSERT, 'Warning:\tInvalid year / year not found\n')
        if len(car_var4) < 9:
            self.scr.insert(tk.INSERT, 'Warning:\tInvalid ip address / ip address not found\n')

        #----------------------------------------------------------------------
        # If valid is entered display the correct data
        #----------------------------------------------------------------------
        if (len(car_var1) > 2) and (len(car_var2) > 0) and (len(car_var3) > 3) and (len(car_var4) > 8):
                # create car object and update labels with car data
                self.chevy = Car.Car(car_var1, car_var2, car_var3, car_var4)   # create a car object
                self.make = self.chevy.getMake()
                self.mode = self.chevy.getModel()
                self.year = self.chevy.getYear()
                self.port = self.chevy.getPortNumber()

                self.scr.insert(tk.INSERT, self.chevy.read_dtc_trace())
                self.scr.insert(tk.INSERT, '\n\nData Trace:\n')
                self.scr.insert(tk.INSERT, '----------------------------------------------------------------------------------------\n')
                self.scr.insert(tk.INSERT, self.chevy.read_uas_trace())

                self.label1 = ttk.Label(self.l1Frame, text='Make : ' + self.make + '\t').grid(column = 0, row = 0)
                self.label2 = ttk.Label(self.l1Frame, text="Model: " + self.mode + '\t').grid(column = 0, row = 1)
                self.label3 = ttk.Label(self.l1Frame, text="Year : " + self.year + '\t').grid(column = 0, row = 2)
                self.label4 = ttk.Label(self.l1Frame, text="PORT : " + self.port + '\t').grid(column = 0, row = 3)
                
                self.label5 = ttk.Label(self.stat_frame, text="Vehicle speed : \t" + str(self.chevy.getSpeed()) + 'KPH').grid(column = 0, row = 0)
                self.label6 = ttk.Label(self.stat_frame, text="Engine speed  : \t" + str(self.chevy.getEngineSpeed()) + 'RPM' ).grid(column = 0, row = 1)
                self.label7 = ttk.Label(self.stat_frame, text="Voltage level : \t" + str(self.chevy.getVoltageLevel()) + 'Volt').grid(column = 0, row = 2)
                self.label8 = ttk.Label(self.stat_frame, text="Pressure level: \t" + str(self.chevy.getPressureLevel()) + 'KPS').grid(column = 0, row = 3)
                self.label8 = ttk.Label(self.stat_frame, text="Current level : \t" + str(self.chevy.getCurrentLevel())  + 'AMP').grid(column = 0, row = 4)
                
                
                self.label4 = ttk.Label(self.l1Frame, text="PORT : " + self.port + '\t').grid(column = 0, row = 3)
                #-------------------------------------------------------------
                fig = Figure(figsize=(12, 8), facecolor='white')
                #-------------------------------------------------------------
                # axis = fig.add_subplot(111)
                # 1 row,  1 column, only graph
                axis = fig.add_subplot(211)     # 2 rows, 1 column, Top graph 
                #-------------------------------------------------------------
                xValues = [1,2,3,4]
                yValues = [5,7,6,8]
                axis.plot(xValues, yValues)
                axis.set_xlabel('Horizontal Label')
                axis.set_ylabel('Vertical Label')
                # axis.grid()                   # default line style 
                axis.grid(linestyle='-')
예제 #26
0
 def __init__(self):
     self.vis = vision.Vision()
     self.cam = camera.Camera()
     self.lines = Lines.Lines()
     self.car = Car.Car()
     self.other_cars = OtherCars.OtherCars()
     self.vacancies = None
     self.frame = None
예제 #27
0
def main():
    all_cars = {}
    car_num = 0
    InputFile = open(sys.argv[1], "r")

    #Adding a car to the dictionary of the cars and assigning the key added the correct properties. (the properties are used in the Car.py module)
    for line in InputFile:
        car_num += 1
        new_line = (line.rstrip("\n")).split(",")
        all_cars[car_num] = Car(car_num, new_line[0], new_line[1], new_line[2],
                                new_line[3])
        all_cars[car_num].width = (all_cars[car_num].coordinates[2] -
                                   all_cars[car_num].coordinates[0])
        all_cars[car_num].height = (all_cars[car_num].coordinates[3] -
                                    all_cars[car_num].coordinates[1])

    return all_cars
 def test_default_car_name(self):
     gm = Car()
     self.assertEqual(
         'General',
         gm.name,
         msg=
         'The car should be called `General` if no name was passed as an argument'
     )
 def test_default_car_model(self):
     gm = Car()
     self.assertEqual(
         'GM',
         gm.model,
         msg=
         "The car's model should be called `GM` if no model was passed as an argument"
     )
예제 #30
0
파일: data_scraper.py 프로젝트: locelus/Car
def scrape_autolist():
    web_cars = driver.find_elements_by_xpath(
        '//div[@class="vehicle-item-view"]')
    cars = []
    for x in web_cars:
        name = x.find_elements_by_xpath('.//div[@class="headline"]')[0].text
        cost = x.find_elements_by_xpath('.//div[@class="headline"]')[1].text
        cars.append(Car(name, cost))
예제 #31
0
    def __init__(self, speed=.014):
        self.__score = 0
        self.__speed = speed

        #Lnked List stores a list of Obstacle objects
        self.__obstacles = adt.LinkedList()
        #Create single object of type car
        self.__auto = cr.Car()
예제 #32
0
import Car
car = Car("Toyota", "Camery", 2015)
car.printDetails()



예제 #33
0
파일: Loop.py 프로젝트: YJoe/TopDownCar
from Car import*

vehicle = Car()


def display_all(main_surface, display_list, text_list):
    main_surface.fill((0, 50, 50))
    for element in display_list:
        element.display(main_surface)
    for element_val in range(0, len(text_list)):
        main_surface.blit(font.render(str(text_list[element_val]), True, (0, 255, 0)), (10, 10 + (10 * element_val)))


def update_all(update_list):
    for element in update_list:
        element.update()


running = True
while running:
    clock.tick(60)
    for event in pygame.event.get():
        if event.type == pygame.QUIT:
            running = False

        if event.type == pygame.KEYDOWN:
            None

    key = pygame.key.get_pressed()
    if key[pygame.K_LEFT]:
        vehicle.left = True
예제 #34
0
from Car import *

# Exercise 1
my_car = Car('Toyota', 'Prius', 0)
your_car = Car('Toyota', 'Camry', 100)

my_car.drive(100)
print(my_car.get_kilometers())  #100

your_car.drive(1000)
print(your_car.get_kilometers())    #1100

# Exercise 2
class Student():
    def __init__(self, name, age, school):
        self.name = name
        self.age = age
        self.school = school

    def get_name(self):
        return self.name

    def get_age(self):
        return self.age

    def get_school(self):
        return self.school

    def set_school(self, school):
        self.school = school