Пример #1
0
 def setUp(self):
     # set up some weights to test with
     # wt[0] => 0 kg weight, wt[1] => 1 kg weight, etc.
     self.wt = []
     for i in range(0, 10):
         name = str(i) + ' kg'
         self.wt += [inventory.Item(name, weight=i)]
Пример #2
0
    def setUp(self):
        # set up Inventory instances to test length and weight restrictions
        self.inv = inventory.Inventory()
        self.inv_len = inventory.Inventory(max_len=3)
        self.inv_wt = inventory.Inventory(max_weight=7)

        # set up Item objects for use
        self.generic1 = inventory.Item('item1')
        self.generic2 = inventory.Item('item2')
        self.generic3 = inventory.Item('item3')
        self.generic4 = inventory.Item('item4')
        self.light = inventory.Item('light', weight=1)
        self.medium = inventory.Item('medium', weight=4)
        self.heavy = inventory.Item('heavy', weight=8)
Пример #3
0
import hashlib
import inventory

name = 'room 4'
win = False

message = False  #variable to keep track of state of engine
password = False  #variable to keep track of state of computer password
inv = inventory.Inventory()  #generate a user inventory
cmd = ''  #variable to keep track of user's commands

cabinet1 = inventory.Inventory()  #create inventory for cabinet 1
cabinet2 = inventory.Inventory()  #create inventory for cabinet 2
cabinet3 = inventory.Inventory()  #create inventory for cabinet 3

CD = inventory.Item('CD', description='a very sharp discus',
                    weight=2)  #create CD item
keycard = inventory.Item('keycard',
                         description='a panacea to your issues',
                         weight=1)  #create keycard item
USB = inventory.Item('USB', description='a wicked device',
                     weight=1)  #create USB item

cabinet1.pick_item(CD)  #put CD in cabinet 1
cabinet2.pick_item(keycard)  #put keycard in cabinet 2
cabinet3.pick_item(USB)  #put USB in cabinet 3


#function to access computer 1
def computer1():
    print "   _______________   "
    print "  |  ___________  |  "
Пример #4
0
'''

import inventory
import hashlib

# room metadata
name = 'room 6'
win = False

# user and room inventory objects
inv = inventory.Inventory()
room_items = inventory.Inventory()

# init the room with some potentially useful items
room_items.pick_item(
    inventory.Item('apple', description='keeps doctors away', weight=1))
room_items.pick_item(
    inventory.Item('banana', description='monkey like', weight=1))
room_items.pick_item(
    inventory.Item('orange',
                   description='not to be compared to apple',
                   weight=1))
room_items.pick_item(
    inventory.Item('chestnut',
                   description='a solid road in Holmdel, NJ',
                   weight=1))
room_items.pick_item(
    inventory.Item('penguin', description='tux, is that you?', weight=3))

# sha256 hash of the 'special object' name, so the casual user looking at the
# source code still doesn't know what the item is
Пример #5
0
   | 3 | | 4 |
   +---+ +---+
'''

##############
# SETUP ROOM #
##############

# the actual values of the machine are stored in an Inventory object
atw_mcn = inventory.Inventory(max_len=5)

# initialize Atwood machine with dummy masses
for i in range(1, atw_mcn.max_len+1):
    n = str(i)+'_kg'
    atw_mcn.pick_item(inventory.Item(n,
                                     description='a '+n+' mass',
                                     weight=i))

# the room's environment can hold unlimited items
room_items = inventory.Inventory()

# initialize room items
axe = inventory.Item('axe',
                    description='a mighty weapon',
                    weight=4)
sword = inventory.Item('sword',
                    description='an awesome weapon',
                    weight=2)
rail_gun = inventory.Item('rail_gun',
                    description='a terrifying weapon',
                    weight=8)
Пример #6
0
import hashlib
import inventory

name = 'room 3'
win = False

engine = False  #variable to keep track of state of engine
password = False  #variable to keep track of state of computer password
inv = inventory.Inventory()  #generate a user inventory
cmd = ''  #variable to keep track of user's commands

cabinet1 = inventory.Inventory()  #create inventory for cabinet 1
cabinet2 = inventory.Inventory()  #create inventory for cabinet 2
cabinet3 = inventory.Inventory()  #create inventory for cabinet 3

welder = inventory.Item('welder', description='a welding tool',
                        weight=3)  #create welder item
hammer = inventory.Item('hammer',
                        description='an exceedingly dangerous weapon',
                        weight=2)  #create hammer item
wrench = inventory.Item('wrench', description='a wretched wrench',
                        weight=2)  #create wrench item

cabinet1.pick_item(welder)  #put welder in cabinet 1
cabinet2.pick_item(hammer)  #put hammer in cabinet 2
cabinet3.pick_item(wrench)  #put wrench in cabinet 3


#function to access computer and password
def computer():
    print "The computer has been accessed."
    global password