示例#1
0
def main():

    start = Location(100, 200)
    end = Location(200, 200)

    anna = HouseWife("Anna", end, 1000, "0")

    ant25 = Plane("ANT25", 10000, 10)
    ant20 = Plane("ant20", 5000, 10)

    inter_city = Train("InterCity", 15)
    chs2 = Train("ChS2", 15)

    sprinter = Bus("Sprinter", 200)
    double_decker = Bus("Double Decker", 100)

    delivery_date = Date(2019, 4, 21)

    urk_air_transport = PlaneDelivery("SlavaUkraini", 100, 1220, start, end,
                                      ant25, delivery_date, anna)
    pl_air_transport = PlaneDelivery("SmertVorogam", 100, 200, start, end,
                                     ant20, Date(2019, 4, 22), anna)

    urk_railway = TrainDelivery("UkrRailway", 1000, 120, start, end,
                                inter_city, Date(2020, 4, 21), anna)
    pl_railway = TrainDelivery("PlRailway", 100, 109, start, end, chs2,
                               Date(2019, 5, 27), anna)

    fed_ex = BusDelivery("FedEx", 100, 1000, start, end, sprinter,
                         Date(2025, 4, 21), anna)
    dhl = BusDelivery("dhl", 200, 57, start, end, double_decker,
                      Date(2030, 1, 2), anna)

    taras_bulba = Book("Taras Bulba", 500, 400, "Nikolya Gogol",
                       urk_air_transport)
    kobzar = Book("Kobzar", 700, 1000, "Taras Shevchenko", pl_air_transport)
    garry_potter = Book("Garry Potter", 100, 250, "Joah Rouling", urk_railway)

    pro_retina_13 = MacBook("Pro Retina 13", 1250, 13, 13, urk_railway)
    pro_retina_15 = MacBook("Pro Retina 15", 2250, 15, 17, fed_ex)
    air_retina_13 = MacBook("Air Retina 13", 1200, 13, 13, pl_railway)

    g403 = ComputerMouse("Logitech g403", 60, 5, 2, dhl)
    netscroll120 = ComputerMouse("Genius netscroll 120", 5, 2, 1, dhl)
    razer_champion = ComputerMouse("Razor Champion", 100, 10, 2, dhl)

    marta = HouseWife("Marta", end, 1000, "BOOKS")
    nina = HouseWife("Nina", end, 100, "PANS")

    amazon_catalog = [taras_bulba, kobzar, pro_retina_13, g403, netscroll120]

    amazon_clients = [marta, nina]

    amazon = Shop("Amazon", "amazon.com", amazon_catalog)

    amazon_manager = ShopManager(amazon_clients, amazon)
示例#2
0
 def __init__(self, name, x, y):
     self.name = name
     self.location = Location(x, y)
     self.shots_left = 5
     self.mines = 1
     self.has_treasure = False
     self.alive = True
示例#3
0
 def read(self):
     rows = Repository().read(self.filename)
     locations = [
         Location(row['country'], row['airport'], row['phone'],
                  row['hours'], row['id']) for row in rows
     ]
     return locations
示例#4
0
def insert_route_data(route_number, route_data):
    route = Route(routeNumber=route_number)
    route.put()

    for record in route_data:
        road_name = record[0]

        #check if road exist if not create one
        road = Road.get_or_insert(road_name, name=road_name)

        #store the location
        location = Location(node=record[2],
                            lat=float(record[3]),
                            lng=float(record[4]),
                            placeId=record[5])
        location.put()

        #map location to the route
        route_location = RouteLocation(nodeIndex=int(record[1]),
                                       route=route.key,
                                       road=road.key,
                                       node=location.key)
        route_location.put()

    return route.key
示例#5
0
文件: dbTools.py 项目: dio-dev/nbu-it
def create_location(region, city, street, building_number, adress_index):
    session.commit()
    location = Location(region, city, street, building_number, adress_index)
    session.add(location)
    session.commit()

    return location
示例#6
0
    def initilise_locations(self):
        f = open("game_info/locations.txt", 'r')
        name, description, loc_objects, destinations = (None, ) * 4

        for line in f:

            if name is None:
                name = self.match_object("name:", line)

            if description is None:
                description = self.match_object("description:", line)

            if loc_objects is None:
                loc_objects = self.match_list("objects:", line)

            if destinations is None:
                destinationsObj = match("destinations:", line)
                if destinationsObj is not None:
                    destinations = [
                        Destination(dest.group(1), dest.group(2)) for dest in
                        finditer(r"\"(.+?)\"\[(.+?)\]", line[14:len(line) - 1])
                    ]

            if match("--", line):
                objects_list = [self.objects[i]
                                for i in loc_objects] if loc_objects else None
                self.locations[name] = Location(name, description,
                                                objects_list, destinations)
                name, description, loc_objects, destinations = (None, ) * 4

        f.close()
示例#7
0
 def __init__(self,*places):
     
     self.id=random.randint(0,100)
     self.places=[]
     for p in places:
         l = Location(p)
         self.places.append(l)
     if len(places) > 0:
         self.details=self.get_summary()
 def addLocation(self, id):
     """Returns JSON object of the created location"""
     try:
         data = LocationService.parser.parse_args()
         location = Location.findLocationById(id)
         if location:
             return "The location already exists!"
         else:
             location = Location(id, data["code"], data["description"], data["x_coor"], data["y_coor"], data["waterschap_id"], data["watertype_id"], data["watertype_krw_id"])
             location.save()
             return location.json()
     except exc.IntegrityError:
         return "The code already exists!"
示例#9
0
def create():
    schema = LocationSchema()

    try:
        data = schema.load(request.get_json())
        location = Location(**data)
        db.commit()
    except ValidationError as err:
        return jsonify({
            'message': 'Validation failed',
            'errors': err.messages
        }), 422

    return schema.dumps(location), 201
示例#10
0
 def __add__(self,other):
     
     if isinstance(other,str):
         newLoc = Location(other)  
         self.places= self.places + [newLoc]
         self.details=self.get_summary()
         return self         
         #return Trip.fromPlaces(id=self.id,places=self.places + [newLoc])
     elif isinstance(other,Trip):
         if self.places[-1].addr == other.places[0].addr:
             newplaces= self.places[:]+other.places[1:]
             #print(newplaces)
             return Trip.fromPlaces(places=newplaces)
         else:
             raise NameError('Trips cannot be combined.')
示例#11
0
 def reload(self):
     self.__previous_state = None
     self.__location = Location()
示例#12
0
        image='https://pbs.twimg.com/profile_images/1095848308361302021/RZrejye3.jpg'
    )
    elle = User(
        username='******',
        email='*****@*****.**',
        password_hash=schema.generate_hash('pass'),
        image='https://media.licdn.com/dms/image/C5603AQHX0omHmh7fWQ/profile-displayphoto-shrink_800_800/0?e=1565222400&v=beta&t=5pP3yPblEgMO-XljaArDpTJJblOqk0dy5L28S3qbWGQ'
    )
    hugo = User(
        username='******',
        email='*****@*****.**',
        password_hash=schema.generate_hash('pass'),
        image='https://media.licdn.com/dms/image/C4E03AQFsE6plNPRwsg/profile-displayphoto-shrink_800_800/0?e=1565222400&v=beta&t=6TGy4Oli2Yc5LRLDCPKuuk850vNQiEUnyVW-g08ocjc'
    )

    amsterdam = Location(name='Amsterdam')
    paris = Location(name='Paris')
    kansas = Location(name='Kansas')
    colombia = Location(name='Colombia')
    austria = Location(name='Austria')
    azerbaijan = Location(name='Azerbaijan')
    belgium = Location(name='Belgium')
    bhutan = Location(name='Bhutan')
    chile = Location(name='Chile')
    copenhagen = Location(name='Copenhagen')
    palestine = Location(name='Palestine')
    london = Location(name='London')
    taiga = Location(name='Taiga')
    oxford = Location(name='Oxford')
    edinburgh = Location(name='Edinburgh')
示例#13
0
with db_session():
    #User
    schema = UserSchema()
    Kristian = User(username='******',
                    email='*****@*****.**',
                    password_hash=schema.generate_hash('pass'))

    # Trips
    trip_one = Trip(name="Trip One", user=Kristian)
    trip_two = Trip(name="Trip Two", user=Kristian)

    # Locations - Trip One
    location_one = Location(name="Clapham Junction",
                            postcode="SW111PW",
                            latitude=51.4652,
                            longitude=-0.1708,
                            trip=trip_one)
    location_two = Location(name="Vauxhall",
                            postcode="SW84ET",
                            latitude=51.4862,
                            longitude=-0.1229,
                            trip=trip_one)
    location_three = Location(name="Southfields",
                              postcode="SW196LL",
                              latitude=51.4448,
                              longitude=-0.2068,
                              trip=trip_one)

    # Locations - Trip Two
    location_four = Location(name="Bethnal Green",
    def create(self):
        counter = 0

        country = ""
        airport = ""
        phone = ""
        hours = ""

        while True:

            self.printer.header("Create location")
            print(
                f"Country:\t\t\t{country}\nAirport:\t\t\t{airport}\nPhone:\t\t\t\t{phone}\nHours:\t\t\t\t{hours}\n"
            )
            self.printer.new_line()
            self.printer.print_fail("Press q to go back")
            self.printer.new_line()
            self.notification()
            next_input = True
            data = None
            try:
                if counter == 0:
                    data = self.input.get_input("country", ["required"],
                                                warning_msg=self.warning_msg)
                    if data[0]:
                        country = data[1]
                    else:
                        next_input = False
                        self.warning_msg = data[1]
                elif counter == 1:
                    data = self.input.get_input("airport", ["required"],
                                                warning_msg=self.warning_msg)
                    if data[0]:
                        airport = data[1]
                    else:
                        next_input = False
                        self.warning_msg = data[1]
                elif counter == 2:
                    data = self.input.get_input("phone", ["required", "phone"],
                                                warning_msg=self.warning_msg)
                    if data[0]:
                        phone = data[1]
                    else:
                        next_input = False
                        self.warning_msg = data[1]
                elif counter == 3:
                    data = self.input.get_input("hours", ["required"],
                                                warning_msg=self.warning_msg)
                    if data[0]:
                        hours = data[1]
                    else:
                        next_input = False
                        self.warning_msg = data[1]
                elif counter > 3:
                    new_location = Location(country, airport, phone, hours)
                    confirmation = input(
                        "Are you sure you want to create this location? (\33[;32mY\33[;0m/\33[;31mN\33[;0m): "
                    ).lower()
                    if confirmation == 'y':
                        self.logic.create_location(new_location)
                        return True
                    return False
                if next_input:
                    counter += 1
            except ValueError:
                break
示例#15
0
 def __init__(self, row, column, walls=None, unbreakable=None):
     self.walls = self.create_walls_dir(walls, unbreakable)
     self.location = Location(row, column)
     self.has_treasure = False
     self.has_armoury = False
示例#16
0
 def get_location_details(self, location_id):
     location = Location(self.__db, location_id)
     if location.exists:
         return [location.name, location.address, location.email]
     else:
         return False