Exemple #1
0
    def add_cars(self):
        if random.randint(0, 4) == 1:
            v_type = random.randint(0, 4)
            if v_type == 3:
                v_type = 1
            else:
                v_type = 0

            add = False
            if len(self.v) > 0:
                if v_type == 0:
                    lv = self.v[-1]
                    if lv.x > 50:
                        add = True
                else:
                    lv = self.v[-1]
                    if lv.x > 100:
                        add = True
            else:
                add = True

            if add:
                new = Vehicle(v_type)
                self.img = PhotoImage(file=new.img)
                self.v.append(new)
                new.id = self.w.create_image(new.x,
                                             self.y1,
                                             image=self.img,
                                             anchor=W)
                new.imgid = self.img
                self.imgs.append(self.img)
                if self.auto_bus_switch == 1 and new.wait != 0:
                    new.wait = 10

            # used for debugging movement
            self.ex_starter = True
Exemple #2
0
# Joe Degere
# 11/11/19
# Homework

from car import Vehicle
# include name, brand, shift, year
myCar = Vehicle('Camero', 'Chevy', 'stick shift', '2019')
myCar.description()
Exemple #3
0
 def test_car_type(self):
     gallardo = Vehicle('gallardo', 'spider', 'saloon')
     self.assertTrue(gallardo.is_saloon(),
                     msg='The type should be a saloon')
Exemple #4
0
 def test_car_doors(self):
     toyota = Vehicle('toyota', 'hiace', 'saloon')
     canter = Vehicle('mitsubishi', 'cantter', 'truck')
     self.assertListEqual(
         [4, 3], [toyota.num_of_wheels, canter.num_of_wheels],
         msg='The car shoud have at least 5 doors unless its a truck')
Exemple #5
0
 def test_car_property(self):
     nissan = Vehicle('nissan', 'xtrail', 'saloon')
     self.assertListEqual(['nissan', 'xtrail'], [nissan.name, nissan.model],
                          msg='Car properties should be valid')
Exemple #6
0
 def test_for_object_instance(self):
     gtr = Vehicle('gtr', 'nissan', 'saloon')
     self.assertIsInstance(gtr, Vehicle, msg="Check Class instance")
Exemple #7
0
 def test_for_invalid_obj(self):
     scania = Vehicle('scania', 'v7', 'truck')
     self.assertTrue(scania.is_saloon(), msg="The type should be a saloon")