예제 #1
0
def add_new_item():
    """ Adds a new item """

    item_code = input("Enter item code: ")
    item_description = input("Enter item description: ")
    item_rental_price = input("Enter item rental price: ")

    # Get price from the market prices module
    item_price = market_prices.get_latest_price(item_code)

    is_furniture = input("Is this item a piece of furniture? (Y/N): ")
    if is_furniture.lower() == "y":
        item_material = input("Enter item material: ")
        item_size = input("Enter item size (S,M,L,XL): ")
        new_item = Furniture(item_code, item_description, item_price,
                             item_rental_price, item_material, item_size)
    else:
        is_electric_appliance = input(
            "Is this item an electric appliance? (Y/N): ")
        if is_electric_appliance.lower() == "y":
            item_brand = input("Enter item brand: ")
            item_voltage = input("Enter item voltage: ")
            new_item = ElectricAppliances(item_code, item_description,
                                          item_price, item_rental_price,
                                          item_brand, item_voltage)
        else:
            new_item = Inventory(item_code, item_description, item_price,
                                 item_rental_price)
    full_inventory[item_code] = new_item.return_as_dictionary()
    print("New inventory item added")
 def test_furniture(self):
     """Tests for Furniture dictionary output"""
     my_inv = Furniture(product_code=12,
                        description='apple chair',
                        market_price=70,
                        rental_price=45,
                        material='apple',
                        size=12)
     inv_dict = my_inv.return_as_dictionary()
     assert inv_dict['product_code'] == 12
     assert inv_dict['description'] == 'apple chair'
     assert inv_dict['market_price'] == 70
     assert inv_dict['rental_price'] == 45
     assert inv_dict['material'] == 'apple'
     assert inv_dict['size'] == 12
예제 #3
0
파일: bed.py 프로젝트: smilehowe/PythonEx
class Bed(Furniture):
    
    def __init__(self):
        self.furniture = Furniture()
    
    def print_define(self):
        self.furniture.print_define()
        print "床是供人躺在上面睡觉的家具。"
    
    def print_classify(self, classify):
        print "床的分类为:%s" % classify
    
    def print_colour(self, colour):
        print "床的颜色是:%s" % colour

        
예제 #4
0
    def build_json_building_at_position(
        self, filename, position
    ):  # applys the json file to world coordinates. can be done over multiple chunks.
        print('building: ' + str(filename) + ' at ' + str(position))
        start = time.time()
        #TODO: fill the chunk overmap tile with this om_terrain
        with open(filename) as json_file:
            data = json.load(json_file)
        #print(data)
        group = data['group']
        overmap_terrain = data['overmap_terrain']
        floors = data['floors']
        #print(floors)
        terrain = data['terrain']  # list
        furniture = data['furniture']  # list
        fill_terrain = data['fill_terrain']  # string

        impassable_tiles = ['t_wall']  #TODO: make this global
        for k, floor in floors.items():
            #print(k)
            i, j = 0, 0
            for row in floor:
                i = 0
                for char in row:
                    #print(char)
                    #print(terrain)
                    impassable = False
                    t_position = Position(position.x + i, position.y + j, k)
                    self.put_object_at_position(
                        Terrain(fill_terrain, impassable),
                        t_position)  # use fill_terrain if unrecognized.
                    if char in terrain:
                        #print('char in terrain')
                        if terrain[char] in impassable_tiles:
                            impassable = True
                        #print('placing: ' + str(terrain[char]))
                        self.put_object_at_position(
                            Terrain(terrain[char], impassable), t_position)
                    elif char in furniture:
                        #print('placing: ' + str(furniture[char]))
                        self.put_object_at_position(Furniture(furniture[char]),
                                                    t_position)
                    else:
                        #print('placed : ' + str(fill_terrain))
                        pass
                    i = i + 1
                j = j + 1
        end = time.time()
        duration = end - start
예제 #5
0
    def populate_map(self, map):
        # define rooms and items
        # furniture
        couch = Furniture("couch")
        piano = Furniture("piano")
        double_bed = Furniture("double bed")
        queen_bed = Furniture("queen bed")
        dresser = Furniture("dresser")
        dining_table = Furniture("dining table")

        # doors
        door_a = Door("door a")
        door_b = Door("door b")
        door_c = Door("door c")
        door_d = Door("door d")

        # keys
        key_a = Key("key for door a", door_a)
        key_b = Key("key for door b", door_b)
        key_c = Key("key for door c", door_c)
        key_d = Key("key for door d", door_d)

        # rooms
        game_room = Room("game room")
        bedroom_1 = Room("bedroom 1")
        bedroom_2 = Room("bedroom 2")
        living_room = Room("living room")
        outside = Room("outside")

        # setting start and end rooms
        map.set_start_room(game_room)
        map.set_end_room(outside)

        # object relations
        map.add_relation("game room", [couch, piano, door_a])
        map.add_relation("bedroom 1", [queen_bed, door_a, door_b, door_c])
        map.add_relation("bedroom 2", [double_bed, dresser, door_b])
        map.add_relation("living room", [dining_table, door_c, door_d])
        map.add_relation("outside", [door_d])
        map.add_relation("piano", [key_a])
        map.add_relation("double bed", [key_c])
        map.add_relation("dresser", [key_d])
        map.add_relation("queen bed", [key_b])
        map.add_relation("door a", [game_room, bedroom_1])
        map.add_relation("door b", [bedroom_1, bedroom_2])
        map.add_relation("door c", [bedroom_1, living_room])
        map.add_relation("door d", [living_room, outside])
예제 #6
0
    "textbooks": [
        Book("UCSMP Pre-Algebra", "Transitions I-II", 600, True),
        Book("UCSMP Algebra", "Algebra I", 650, True),
        Book("UCSMP Geometry", "Geometry", 700, True),
        Book("UCSMP Advanced Algebra", "Algebra II", 750, True)
    ],
    "stationery": [
        Stationery("ruler", 12, "blue", 10, "measuring"),
        Stationery("pencil", 8, "yellow", 25, "writing"),
        Stationery("eraser", 2, "pink", 20, "erasing"),
        Stationery("protractor", 10, "transparent", 10, "measuring angles"),
        Stationery("compass", 6, "black", 5, "drawing circles"),
        Stationery("graph paper", 20, "yellowish", 75, "being written on")
    ],
    "furniture":
    (Furniture("table", 5, 4, "wood",
               4), Furniture("chair", 3, 4, "metal",
                             12), Furniture("whiteboard", 7, 6, "plastic", 2)),
    "students": [Student("Mallika", True, 14, 5, 1, 9, 'student')]
}

print("{} is our {} teacher".format(math_classroom['teacher'].name,
                                    math_classroom['teacher'].subject))
math_classroom['teacher'].teach()
print('\n')

for textbook in math_classroom['textbooks']:
    print("Our textbook for {} is {} - it has {} pages".format(
        textbook.topic, textbook.title, textbook.pages))

print('')
for item in math_classroom['stationery']:
예제 #7
0
       str(int(pos[1] / 24)))
 if (event.button == 1):
     if (editor.selected_item is not None):
         editor.building_layout[int(pos[0] / 24)][int(
             pos[1] /
             24)][editor.curFloor]['items'].append(
                 Item(editor.selected_item))
     elif (editor.selected_furniture is not None):
         editor.building_layout[int(pos[0] / 24)][int(
             pos[1] / 24
         )][editor.curFloor]['terrain'] = Terrain(
             editor.fill_terrain
         )  # can only place furniture on fill_terrain otherwise the chars would overwrite each other.
         editor.building_layout[int(pos[0] / 24)][int(
             pos[1] / 24
         )][editor.curFloor]['furniture'] = Furniture(
             editor.selected_furniture)
     elif (editor.selected_terrain is not None):
         editor.building_layout[int(pos[0] / 24)][int(
             pos[1] /
             24)][editor.curFloor]['terrain'] = Terrain(
                 editor.selected_terrain)
         editor.building_layout[int(pos[0] / 24)][int(
             pos[1] /
             24)][editor.curFloor]['furniture'] = None
 elif (event.button == 3):
     editor.building_layout[int(pos[0] / 24)][int(
         pos[1] / 24)][editor.curFloor]['items'] = []
     editor.building_layout[int(pos[0] / 24)][int(
         pos[1] /
         24)][editor.curFloor]['furniture'] = None
     editor.building_layout[int(pos[0] / 24)][int(
예제 #8
0
def furniture_menu():

    furniture_menu = ''' Furniture Managment System
               1. Add Furniture 
               2. View Furniture
               3. Search Furiture
               4. Exit 
               '''

    while True:
        # receive data stream. it won't accept data packet greater than 1024 bytes
        try:
            conn.send(bytes(furniture_menu, 'utf-8'))
            data = conn.recv(1024).decode()

            if data.lower().strip() == "1":
                data = "Adding Furniture to the System:"
                conn.send(data.encode())
                data = conn.recv(1024)
                data = json.loads(data.decode())
                new_data = data["Add"]
                f1 = Furniture(new_data['Name'], new_data['Type'],
                               new_data['Category'], new_data['WoodType'],
                               new_data['Color'], new_data['Size'])
                f1.file_handling(f1.data_dict())
                notify = json.dumps(f1.Details())
                conn.send(notify.encode())
                print(data["Add"])

            elif data.lower().strip() == "2":
                # data = "All the furniture in the System:"
                # conn.send(data.encode())
                f1 = Furniture()
                data = f1.view_furniture()
                data = json.dumps(data)
                conn.send(data.encode())

            elif data.lower().strip() == "3":
                data = "Provide Id for furniture:"
                conn.send(data.encode())
                client_data = conn.recv(1024)
                f1 = Furniture()
                data = f1.search_furniture(client_data.decode())
                data = json.dumps(data)
                conn.send(data.encode())

            # elif data.lower().strip() == "exit" or data.lower().strip() == "4":
            #     # if data is not received break
            #     data = "Exiting...bye"
            #     conn.send(data.encode())
            #     conn.close()
            #     break

            elif data.lower().strip() == "":
                print("data recieved")
                data = "Wrong choice...Try again with mentioned choice"
                conn.send(data.encode())
                continue
        except ConnectionAbortedError:
            print("Client Exited")
            break

    conn.close()
예제 #9
0
파일: bed.py 프로젝트: smilehowe/PythonEx
 def __init__(self):
     self.furniture = Furniture()