Пример #1
0
    def order_question(self):
        #반복↓

        while True:
            #show menu
            # self.menu()

            print("1.학교에서\
                2.회사에서\
                3.공공장소에서\
                4.일상생활에서 ")

            User_S = input("알고싶은 문장의 번호를 선택하세요")

            if User_S == "":  #사용자가 엔터를 치면 끝난다.
                break
            elif User_S == '1':  #1을 누르면 school.py를 불러와서 실행
                s = School()
                s.run(User_S)
            elif User_S == '2':  #2을 누르면 school.py를 불러와서 실행
                o = Office()
                o.run(User_S)
            elif User_S == '3':  #3을 누르면 school.py를 불러와서 실행
                p = Public()
                p.run(User_S)
            elif User_S == '4':  #4을 누르면 school.py를 불러와서 실행
                l = Life()
                l.run(User_S)
Пример #2
0
    def load_room_state(self, db_name='amity'):
        """Loads room state from sqlite db"""

        self.util.db.table_name = 'room'
        rooms = self.util.db.find_all()
        if not rooms:
            Util.print_line('No rooms record found')
            return False

        for row in rooms:
            if row['type'] == 'OFFICE':
                room = Office(str(row['name']))
            else:
                room = LivingSpace(str(row['name']))

            if int(row['allocated']) > 0:
                self.util.db.table_name = 'person'
                people = self.util.db.execute(
                    'SELECT * FROM person WHERE assigned_room LIKE "%' +
                    room.name + '%"')
                for item in people:
                    person = self.get_person(item)
                    room.allocate(person, False)
            self.rooms.append(room)
        return True
Пример #3
0
    def fellower():
        o = "office"
        l = "living"
        option = raw_input(
            "How do you intend to use the room ether office or living::")

        if option == o:
            Office.office_space()  #calls the office function
        elif option == l:
            Living.living_room()  #call living function
        else:
            print "Invalid option try again"
Пример #4
0
class Amity(object):
    def __init__(self):
        print("Welcome to Amity\n")
        self.office = Office()
        self.livingspace = LivingSpace()
        self.staff = Staff()
        self.fellow = Fellow()

    def ready(self):
        command = None
        while command != "exit":
            command = self.get_input()
            if command.lower() == "exit":
                command = "exit"
            else:
                method_params = map(str.lower, command.split())
                getattr(self, method_params[0])(method_params[1::])
        return

    def get_input(self):
        return raw_input(">> ").strip()

    """
     create_room OFFICE carat vvida minion
     create_room LIVINGSPACE carat vvida minion
    """

    def create_room(self, rooms):
        if rooms[0] == "office":
            self.office.create(rooms)
        else:
            self.livingspace.create(rooms)

    """
    add_person bukky FELLOW Y
    add_person tosin STAFF
    """

    def add_person(self, person_details):
        if len(person_details) == 2:
            person_details.append("N")

        if person_details[1] == "fellow":
            self.fellow.add(person_details)
            self.fellow.allocate_room(self.office, self.livingspace)
        else:
            self.staff.add(person_details)
            self.staff.allocate_room(self.office)
Пример #5
0
def openInput(name):
    # Open text file and store bag of lines
    file_contents = open(input_files[name], 'r')
    with file_contents as fc:
        content = fc.readlines()

    # Parse first line into a Map object
    width, height = content[0].split(' ')
    office = Office(name, width, height, content[1:int(height) + 1])

    num_devs = int(content[int(height) + 1])
    developers = [
        Developer(line)
        for line in content[int(height) + 2:int(height) + 2 + num_devs]
    ]
    developers = developers.sort(
        key=lambda developers:
        (developers.ci, developers.bi, developers.num_s),
        reverse=True)

    manager_start = int(height) + 1 + num_devs + 1
    num_managers = int(content[manager_start])

    managers = [Manager(line) for line in content[manager_start + 1:]]
    managers = managers.sort(key=lambda managers: (managers.ci, managers.bi),
                             reverse=True)

    # Return both Map and Customer objects
    return office, developers, managers
Пример #6
0
    def create_room(self, room_list, room_type):
        """Function to create offices and living spaces!"""
        rooms = ""
        for room in room_list:
            if room in [room_object.room_name for room_object in self.rooms]:
                print("cannot create room {} . The room already exists."
                      .format(room))
                rooms += "cannot create room {} . The room already exists."\
                    .format(room)

            else:
                if room_type == "office":
                    office = Office(room)
                    self.rooms.append(office)
                    self.offices.append(office)
                    print("Office {} of id - {} successfully created"
                          .format(office.room_name.upper(), office.room_id))
                    rooms += "Office {} of id - {} successfully created"\
                        .format(office.room_name.upper(), office.room_id)

                elif room_type == "living_space":
                    living_space = LivingSpace(room)
                    self.rooms.append(living_space)
                    self.living_spaces.append(living_space)
                    print("Living Space {} of id - {} successfully created"
                          .format(living_space.room_name,
                                  living_space.room_id))
                    rooms += "Living Space {} of id - {} successfully "\
                             "created"\
                        .format(living_space.room_name, living_space.room_id)
        return rooms
Пример #7
0
    def create_room(self, room_type, room_name):
        """Creates a new room of given name and type"""
        room_type = room_type.lower()

        if room_type == "office":
            if room_name in self.all_office_names:
                print("A room with this name already exists. Try another name.")
            else:
                new_office = Office(room_type, room_name)
                self.all_office_names.append(room_name)
                self.all_offices.append(new_office)
                print(
                    "The office named {0:s} has been created".format(room_name))

        elif room_type == "livingspace":
            if room_name in self.all_living_space_names:
                print("A room with this name already exists. Try another name.")
            else:
                new_room = LivingSpace(room_type, room_name)
                self.all_living_space_names.append(room_name)
                self.all_living_spaces.append(new_room)
                print(
                    "The living space named {0:s} has been created".format(room_name))
        else:
            print("Room type must be either office or livingspace")
Пример #8
0
def office():
    form = Office()
    doct = Doctor(db.get_connection())
    info = doct.Office(session['user_id'])
    form.id.data = info[0]
    form.fio.data = info[1]
    form.tel.data = info[2]
    form.mail.data = info[3]
    form.field.data = info[4]
    return render_template('office.html', title='Личный кабинет', form=form)
Пример #9
0
    def __init__(self, size=(50, 50)):

        # Store dimensions of office space (default is 50x50)
        self.xlim = size[0]
        self.ylim = size[1]

        # We always have a 'home' at (0,0)
        self.home = Office()

        # Offices are stored in a hash table {coordinates : office}
        self.offices = {(0, 0): self.home}
Пример #10
0
	def create_room(self, room_type, room_name):
		self.create_room = create_room
		self.room_type = room_type
		self.room_name = room_name

		if room_type == "office":
			office = Office(office_name)
			self.list_of_rooms.Append(office)
			return "You have created room '+room_name+' which  an office"
		elif room_type == "living_space":
			living_space = LivingSpace(living_space_name)
			self.list_of_rooms.Append(living_space)
Пример #11
0
 def create_room(self, room_type, room_name):
     if room_type is None or room_name is None:
         return "Must set room_name and room_type"
     else:
         if self.check_room_exists(room_name) is False:
             if room_type == 'office':
                 new_office = Office(room_type, room_name)
                 self.offices_created.append(new_office)
                 return "An office called " + room_name + " has been successfully created!"
             if room_type == 'livingspace':
                 new_livingspace = LivingSpace(room_type, room_name)
                 self.livingspaces_created.append(new_livingspace)
                 return "A livingspace called " + room_name + " has been successfully created!"
         else:
             return room_name + " already exists"
Пример #12
0
    def create_room(self, args):
        """Creates room(s) and save to pickle"""

        room_names = args['<room_name>']
        room_types = args['<room_type>']
        for name, room_type in zip(room_names, room_types):
            if room_type.upper() == 'OFFICE':
                room = Office(name.upper())
            else:
                room = LivingSpace(name.upper())

            if self.room_exists(room):
                Util.print_line(room.name + ' already exists')
            else:
                self.rooms.append(room)
                print room.name + ' successfully created'
        self.save_state_to_pickle()
Пример #13
0
 def get_offices(self):
     # TODO: Periodic refresh of these too
     offices = Office.query.filter_by(cp_id=self.id).all()
     if len(offices) == 0:
         offices = []
         gpo_offices = self.gpo.get_offices(self.get_last_name(),
                                            self.get_first_name())
         for gpo_office in gpo_offices:
             office_dict = {
                 'cp_id': self.id,
                 'city': gpo_office['City'],
                 'phone': gpo_office.get('Phone', None),
                 'info_json': json.dumps(gpo_office),
             }
             office = Office(**office_dict)
             offices.append(office)
             db.session.add(office)
             try:
                 db.session.commit()
             except IntegrityError as e:  # FIXME: e.g. Eliot Engel
                 print e
                 db.session.rollback()
     return offices
Пример #14
0
LivingRoom = LivingRoom(0, 0)
DarkHallway = DarkHallway(0, 1)
ServantQuarters = ServantQuarters(1, 0)
MusicRoom = MusicRoom(1, 1)
Library = Library(1, 2)
row1 = [LivingRoom, DarkHallway]
row2 = [ServantQuarters, MusicRoom, Library]
floor2_map = [row1, row2]
# ------------------------------------------------------------+
# ------------------------------------------------------------+
FuseRoom = FuseRoom(0, 0)
ThirdBathroom = ThirdBathroom(0, 1)
HiddenRoom = HiddenRoom(0, 2)
ArtRoom = ArtRoom(1, 0)
Hallway = Hallway(1, 1)
Office = Office(1, 2)
row1 = [FuseRoom, ThirdBathroom, HiddenRoom]
row2 = [ArtRoom, Hallway, Office]
floor3_map = [row1, row2]

# ------------------------------------------------------------+


# Function to return the current floor.
def current_floor(x, y, player):
    # Return the current floor
    # according to the player's position.
    if player.current_floor == "floor1":
        return floor1_map[x][y]
    elif player.current_floor == "floor2":
        return floor2_map[x][y]
Пример #15
0
p2 = Package(num_packages,101,102)
num_packages += 1
p3 = Package(num_packages,201,101)
num_packages += 1
p4 = Package(num_packages,201,101)
num_packages += 1
p5 = Package(num_packages,201,101)

print('### Printing some packages')
print(p1)
print(p2)
print(p5)

print('----------------------')

o101 = Office(101)
o102 = Office(102)
o201 = Office(201)


print('### Office 101 wants to mail out 2 packages to Office 102')
o101.add_package_to_mailout(p1)
o101.add_package_to_mailout(p2)
print(o101)

print('----------------------')

print('### Office 201 wants to mail out 3 packages to Office 101')
o201.add_package_to_mailout(p3)
o201.add_package_to_mailout(p4)
o201.add_package_to_mailout(p5)
Пример #16
0
from office import Office
from bank import Bank


bank = Bank("Open Bank")
office = Office("Timisoara", bank)

office.open()
Пример #17
0
    office_util.random_customer
]
agent_selection_strategies = [
    office_util.longest_stage, office_util.shortest_stage,
    office_util.random_agent
]

for cs in customer_selection_strategies:
    for ags in agent_selection_strategies:
        total_times = []
        per_customer_times = []
        for i in range(10):  # simulate each combination 10 times
            office = Office(stages,
                            arrival_rate=office_util.all_at_start(
                                3600, num_customers),
                            customer_selection_strategy=cs,
                            agent_selection_strategy=ags,
                            enable_gui=False,
                            debug=False)

            current_time = 0
            continue_simulate = True

            while (continue_simulate):
                continue_simulate, current_time = office.simulate()

            # all customers are finished and customer.waiting_since contains their completion timestamp
            avg_processing_time = int(
                round(
                    sum([(c.waiting_since - c.token_time)
                         for c in office.customers]) / float(num_customers)))
Пример #18
0
 def __init__(self):
     print("Welcome to Amity\n")
     self.office = Office()
     self.livingspace = LivingSpace()
     self.staff = Staff()
     self.fellow = Fellow()
Пример #19
0
from office import Office
from person import Person


def print_emplopyees():
    print('List of employees:')
    for employee in ecorus.people_working:
        print(f' - {employee.name}, {employee.age}')


ecorus = Office('Ecorus')

eduardo = Person('Eduardo', 38)
levi = Person('Levi', 19)

ecorus.start_working_for(levi)
ecorus.start_working_for(eduardo)

print_emplopyees()

ecorus.finished_working_for(eduardo)
print('\nremoved Eduardo from working.\n')

print_emplopyees()
Пример #20
0
 def setUp(self):
     self.amity = Amity()
     self.fellow = Fellow()
     self.Staff = Staff()
     self.office = Office()
     self.livingspace = LivingSpace()
Пример #21
0
 def addJsonFile(self, json_file):
     json_data = json.loads(json_file)
     for office in json_data['offices']:
         self.addOffice(
             Office(office['name'], (office['x_coord'], office['y_coord'])))
Пример #22
0
    def load_state(self, database=None):
        database = './files/' + database
        """Function to load people from a database"""
        try:
            db = database if database else "amity.db"
            connection = sqlite3.connect(db)
            cc = connection.cursor()
            cc.execute("SELECT * FROM person")
            people = cc.fetchall()
            for person in people:
                if person[2] == 'staff':
                    staff = Staff(person[1], person[2], person[3])
                    staff.person_id = person[0]
                    self.people.append(staff)
                    self.staff.append(staff)

                else:
                    fellow = Fellow(person[1], person[2], person[3])
                    fellow.person_id = person[0]
                    self.people.append(fellow)
                    self.fellows.append(fellow)

            cc.execute("SELECT * FROM room")
            rooms = cc.fetchall()
            for room in rooms:
                if room[2] == 6:
                    office = Office(room[1])
                    office.room_id = room[0]
                    office.room_members = [person for person in self.people if
                                           person.person_id in [int(str(person_id))
                                                                for person_id in
                                                                room[4].split(',')]
                                           ]
                    self.rooms.append(office)
                    self.offices.append(office)
                else:
                    living_space = LivingSpace(room[1])
                    living_space.room_id = room[0]
                    living_space.room_members = [person for person in self.people
                                                 if person.person_id in
                                                 [int(str(person_id)) for
                                                  person_id in room[4].split(',')]
                                                 ]
                    self.rooms.append(living_space)
                    self.living_spaces.append(living_space)

            cc.execute("SELECT * FROM office_waiting_list")
            office_waiting_list = cc.fetchall()
            for person_object in office_waiting_list:
                for individual in self.people:
                    if individual.id == person_object[3]:
                        self.waiting_list.append(individual)
                        self.office_waiting_list.append(individual)

            cc.execute("SELECT * FROM living_space_waiting_list")
            living_space_waiting_list = cc.fetchall()
            for person_object in living_space_waiting_list:
                for individual in self.people:
                    if individual.id == person_object[3]:
                        self.waiting_list.append(individual)
                        self.living_space_waiting_list.append(individual)

            connection.commit()
            connection.close()
            print("Data successfully loaded to amity!")
        except NoDataFound:
            print("Please add data to the database!")
Пример #23
0
 def member():
     Office.office_space()  #calls the office function.