Class Design: Designing a 4S shop that sells cars

class Car(object):
    # How to define the car
    def move(self):
        print('---the car is moving---')
    def stop(self):
        print('---parking---')

# Define a shop class that sells cars
class CarStore(object):
    def order(self):
        car = Car() # find a car
        return car

# 1. Get a store that sells cars
car_store = CarStore()
# car_store.order().move()
# 2. Book a car through this store
my_car = car_store.order()
# 3. Drive cool
my_car.move()
my_car.stop()

  

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325945775&siteId=291194637