To complete this checkpoint you must have completed Modules 1, 2, 3 and 4.
In this exercise you will be required to model a room allocation system for one of Andela’s facilities called Amity.
Amity has rooms which can be offices or living spaces. An office can accommodate a maximum of 6 people. A living space can accommodate a maximum of 4 people.
A person to be allocated could be a fellow or staff. Staff cannot be allocated living spaces. Fellows have a choice to choose a living space or not.
This system will be used to automatically allocate spaces to people at random.
For this task you are required to model the entire system using class definitions. Create the following classes and implement the required functionality within them - Person
, Fellow
, Staff
, Amity
, Room
, Office
, Living Space
.
Ensure that you are properly structuring your class files and using easily navigable folder structures.
You should have UML Class Diagrams for your system. Keep the diagrams in a /designs folder.
Create tests for the models you just created in the previous exercise that ensure the functionality created in the classes are working.
You are then advised to schedule a Test-Cases review with your Simulations Facilitator before you can proceed with Task 2.
After reading through this task, jump to task 2.5 and then come back here.
For this task you are required to create a command line interface using docopt that does the following using your models.
-
create_room <room_name>
... - Creates rooms in Amity. Using this command I should be able to create as many rooms as possible by specifying multiple room names after the create_room command. -
add_person <person_name> <FELLOW|STAFF> [wants_accommodation]
- Adds a person to the system and allocates the person to a random room.wants_accommodation
here is an optional argument which can be eitherY
orN
. The default value if it is not provided isN
. -
reallocate_person <person_identifier> <new_room_name>
- Reallocate the person withperson_identifier
tonew_room_name
. -
load_people
- Adds people to rooms from a txt file. See Appendix 1A for text input format. -
print_allocations [-o=filename]
- Prints a list of allocations onto the screen. Specifying the optional -o option here outputs the registered allocations to a txt file. See Appendix 2A for format. -
print_unallocated [-o=filename]
- Prints a list of unallocated people to the screen. Specifying the -o option here outputs the information to the txt file provided. -
print_room <room_name>
- Prints the names of all the people inroom_name
on the screen. -
save_state [--db=sqlite_database]
- Persists all the data stored in the app to a SQLite database. Specifying the--db
parameter explicitly stores the data in thesqlite_database
specified. -
load_state <sqlite_database>
- Loads data from a database into the application.
For this project you are expected to use TDD. What this means is that you will be writing tests before you create functionality. Just as a rule of thumb before creating any function in the previous task, ensure you have written at the very least, an empty test for it.
Ensure you have test coverage of over 70% at the end of the project.
You may now proceed with Task 2.
OLUWAFEMI SULE FELLOW Y
DOMINIC WALTERS STAFF
SIMON PATTERSON FELLOW Y
MARI LAWRENCE FELLOW Y
LEIGH RILEY STAFF
TANA LOPEZ FELLOW Y
KELLY McGUIRE STAFF
ROOM NAME
-------------------------------------
MEMBER 1, MEMBER 2, MEMBER 3
ROOM NAME
-------------------------------------
MEMBER 1, MEMBER 2
You are free to add on extra functionality beyond what’s specified in the specifications. You are encouraged to do this to exceed expectations.
-
Clone Repo:
$ git clone git@github.com:asce1062/cp1-amity-allocation.git
-
Navigate to local directory.
$ cd cp1-amity-allocation
-
Install virtualenv via pip:
$ pip install virtualenv
-
Install virtualenvwrapper via pip:
$ pip install virtualenvwrapper $ export WORKON_HOME=$HOME/.virtualenvs $ export PROJECT_HOME=$HOME/Devel $ source /usr/local/bin/virtualenvwrapper.sh $ source ~/.bashrc $ mkvirtualenv amity $ workon amity
-
Install requiremets
$ pip install -r requirements.txt
-
Start the application
$ python amityville.py -i
-
create_room <room_name> <room_type>
Usage :create_room moon livingspace
- Creates a roommoon
which is alivingspace
. -
add_person <person_name> <job_description> [<wants_accommodation>]
Usage :add_person aleximmer fellow yes
- Adds a personaleximmer
who is afellow
and wants alivingspace
. -
allocate_livingspace <fellow_name>
Usage :allocate_livingspace aleximmer
- Allocates arandom livingspace
from a list oflivingspaces
that have not reached themaximum capacity
. -
allocate_office <person_name>
Usage :allocate_office aleximmer
- Allocates arandom office
from a list ofoffices
that have not reached themaximum capacity
. -
reallocate_person <person_id> <room_name>
Usage :reallocate_person f1 moon
- Re-allocates a person byperson_id
to aroom
who's name is specified. Printpeople_ids
using theprint_people_details
command. -
load_people [--o=filename]
Usage :load_people --o=people
- loads people from a text file who's name is specified. You must have the text file created first before using this command. -
load_rooms [--o=filename]
Usage :load_rooms --o=rooms
-loads rooms
from a text file who'sname
is specified. You must have the text file created first before using this command. -
print_allocations [--o=filename]
Usage :print_allocations --o=allocations
- Printsall allocations
to a text file if thefilename
option is provided. Else it prints out to screen. -
print_specific_room_allocations <room_name>
Usage :print_specific_room_allocations moon
- Prints all people allocated to the specifiedroom_name
-
print_unallocated [--o=filename]
Usage :print_unallocated --o=unallocations
- Printsall unallocations
to a text file if thefilename
option is provided. Else it prints out to screen. -
print_rooms
Usage :print_rooms
- Prints alloffices
andlivingspaces
available in amity. -
print_fellows
Usage :print_fellows
- Prints allfellows
at amity. -
print_staff
Usage :print_staff
- Prints allstaff
at amity. -
print_all_people
Usage :print_all_people
- Prints allstaff
andfellows
at amity. -
print_people_details
Usage :print_people_details
- Prints allpeople_details
ofpeople
at amity. Format beingID
:name
,job_description
,accommodation_choice
-
create_db [--db=dbname]
Usage :create_db --db=cp1
- Creates adatabase
namedcp1
and populates it with all the tables specified indatabase_models
-
save_state [--db=dbname]
Usage :save_state --db=cp1
- Saves tha program'sstate
to the databsecp1
if no database name is provided, a database namedamity
is created and the programstate
is saved to it. -
load_state [--db=dbname]
-Usage :load_state --db=cp1
- Loads thesaved
programstate
back to the application. If no database name is provided, it will use a database namedamity
. -
clear_db [--db=dbname]
Usage :clear_db --db=cp1
-Clears
the database for a fresh start. If no database name is provided, the database namedamity
is cleared. -
delete_person <person_id>
Usage :delete_person f1
-Deletes
aperson
with theID
F1
from amity allocation system. -
delete_room <room_name>
Usage :delete_room moon
-Deletes
theroom
moon
from amoty. -
clear
Usage :clear
- Clears the terminal output for a cleaner environmet to work on. -
quit
Usage :quit
- Exits the application. -
(-i | --interactive)
Usage :python amityville.py -i
- Start amityville ininteractive
mode. -
(-h | --help | --version)
Usage :python amityville.py -h
- Prints out theUsage
,Arguments
andOptions
and exits the application.
<room_name>
The name of the room<room_type>
The type of room it can either be an office|living_space<person_name>
The name of the employee<job_description>
The employee's job type it can either be fellow|staff[<wants_accommodation>]
Can either be yes|no if not provided defaults to no<fellow_name>
The name of a fellow<person_id>
The ID of the person[--o=filename]
The name of the text file to write to or read from[--db=dbname]
The name of the database to write to or read from if not provided defaults to amity.
-i, --interactive Interactive Mode
-h, --help Show this screen and exit.