Final project of Oriented Object programming at CentraleSupélec
Final project of Oriented Object programming at CentraleSupélec
The documentation of this project is available here
The coverage report of this project is available here
A bicycle sharing system (like, for example, Velib in Paris) allows inhabitants to rent bicycles
and cycle around a metropolitan area. Such a system consists of several interacting parts
including: the renting stations (displaced in key points of a metropolitan area), dierent
kind of bicycles (mechanical and electrically assisted), the users (which may posses a reg-
istration card), the maintenance crew (responsible for collecting/replacing broken down
bicycles), etc.
[x] Station : a station is where bicycles can be rented
and dropped
. It consists of a
number of ``parking slots`` where bicycles are stored and of a ``terminal`` which users can
interact with in order for ``renting bicycles``. Parking slots can be be occupied by a
``bicycle``, ``free`` or ``out-of-order``. A station is located in a specific place specified by ``GPS
coordinates``. A station can be ``on service`` or ``offine``: if it is offine all of its parking
bays as well as the terminal cannot be used. There exist two types of ``stations``,
a ``standard`` type, and a ``plus`` type. When a user who hold a Velib card drops a
bicycle to a ``plus`` station it earns ``5 minutes credits`` in its ``time balance``. Each station
has a ``unique numerical ID`` and so each parking slot (within a station) has a unique
numerical ID.
[x] Bicycle : there exists two kind of bicycles, mechanical
and electrical
. Each bicycle
has a unique numerical ID.
name
, a unique numerical ID
, a geographical position
(GPS coordinates)
a ``credit card`` and might have a ``registration card``. In case a user holds a card she has
also a ``time-credit balance`` (expressed in minutes) representing the credit gained by
returning bicycles to "plus" stations. The time credit is used to compute the actual
cost of a bicycle ride. The user has also a ``balance of total charges`` representing the total
amount of money she has been charged for using bicycle of the myVelib system.
Vlibre
and Vmax
On returning of a velib to a station the system will (automatically) compute the corresponding cost of the ride based on the ride duration (in minutes), the kind of bicycle, and on
the type of card a user has.
no card
the cost is 1 Euro per hour (for mechanical bicycles)
and 2 Euro
per hour (for electrical bicycles)
Vlibre
card the cost is: 0 Euro for the first hour then 1 euro per each
successive hour (for mechanical)
and 1 Euro for the first hour then 2 euros per each
successive hour (for electrical bicycles)
. If a ride lasts longer than 60min the actual[x] The myVelib system must be equipped with a functionality that helps users to plan a ride
from a starting location to a destination location. Given the starting and destination GPS
coordinates the ride planning functionality will identify the \optimal” start and end stations
from/to where the bicycle should be taken/dropped according to the following criteria:
[x] the start, respectively the end, station, for a ride should be as close as possible to
the starting, respectively to the destination, location of the ride.
OPTIONAL ride-planning policies
plus
stations: like minimal walking distance but return station cannot beplus
stationplus
stations: with this policy the return station should be a plus
plus
station no further away than 10% of the distance of theplus
station existsThe myVelib system should support the following functionalities for computing relevant
statistics:
rate = (sum(i=1, numberOfParkingSlots, ti ^ delta) / (delta * numberOfParkingSlots);
where N is the number of parking slots in the station, ti
is the time the i-th slot
has being occupied during the time window [ts; te]. Notice that in the computation
of occupation rate of a station if a parking slot is out-of-service then it should be
accounted as being occupied (independently of whether it holds a bicycle or not).
Furthermore myVelib should support different policies for sorting stations including
those based on the following criteria:
- [x] most used station: stations are sorted w.r.t. the total number of renting + dropping operations
- [ ] least occupied station: stations are sorted w.r.t. the rate of occupation (ratio
between free time over occupied time of parking bays). This allows for figure out
policy to increase the use of less occupied stations (for example by electing the least
occupied stations to the ``plus`` category so to attract users to drop bicycles).
Remark (``an OPEN-CLOSE solution``). Your design should match as much as possible
the open-close principle. Using of design patterns should be properly documented in the
project report explicitly describing to fulfil which requirement of the myVelib system a
design pattern has been applied.
## 2.5 Use case scenario
In order to further guide you in the process of designing/developing the core infrastructure
for the myVelib system you should take into account the following use case scenario which
describe a few examples of realistic interactions between the user of the myVelib system
and the myVelib framework.
### Setting up of myVelib
- [x] The user sets up an instance of the myVelib system: he/she create a myVelib with N
stations, summing up to a total of M parking slots, the 70% of which is occupied by
available bicycles (30% of which are electrical the rest mechanical). The N stations
should be placed randomly (in a uniform manner) over a square surface of area 1010
square kilometres (roughly the surface of Paris intramuros).
- [x] The user add some user to the myVelib system some of which are card holder, some
not.
### Rental of a bicycle
- [x] a user (card holder or not) rent a bicycle of a given type from a given station at a given
moment in time
- [x] the user returns the bicycle to another station after a given duration (expressed in
minutes).
- [x] the user get charged for the corresponding amount (possibly 0) and possibly receive
a time-credit (possibly 0)
### Visualisation of user, station and system state
- [x] a manager (or a user) of myVelib request to see the current state of a user with given
ID
- [x] the system displays a report of the requested user (including its balance, time credit,
number of rides, etc).
- [x] a manager (or a user) of myVelib request to see the current state of a station with
given ID
- [x] the system displays a report of the requested station (including num. of free/occupied
slots, current state, its occupation etc)
- [x] a manager (or a user) of myVelib request to see the current state of a the entire
system
- [x] the system displays a summary report of the system (including list of online/oine
stations, list of users of myVelib , etc.)
### Simulation of a planning ride
- [x] a user at a given position require a ride planning to reach a destination position
- [x] the user receives the source and destination stations
- [x] the user retrieve a bicycle from the source station of the planned ride at a given
instant of time
- [x] the user that is holding a bicycle returns it (in a given free slot) at a given station at
a given instant of time.
### Computation of statistics
- [x] the myVelib system stores relevant data in form of records representing N rental bicycle
simulations (by dierent users, on dierent stations, and with dierent duration)
- [x] the statistics (computed w.r.t. the rental records added in previous step) for each
user are displayed
- [x] the statistics (computed w.r.t. the rental records added in previous step) for each
station are displayed
- [x] stations are displayed sorted w.r.t. the most used station (first)
- [ ] stations are displayed sorted w.r.t. the least occupied station (first)
# 3 Part 2: myVelib user interface
The part 2 of the project is about realising a user interface for the myVelib-app. The
user interface consists a command-line user interface (CLUI). [For insights about CLUI
see](https://en.wikipedia.org/wiki/Command-line_interface) and some examples in
[Java](https://dzone.com/articles/java-command-line-interfaces-part-29-do-it-yoursel)
## 3.1 myVelib CLI: Command line (user) interface
The command line interpreter provides the user with a (linux-style) terminal like environment to enter commands to interact with the myVelib core. A command consists of the
command-name followed by a blank-separated list of (string) arguments:
````shell
command-name <arg1> <arg2> ... <argN>
a command without argument is denoted command-name <>
.
For example the myVelib CLI command for setting up a myVelib system consisting of 10
stations each of which has 10 parking bays and such that the initial population of bicycle
is 75% of the total number of parking bays in the system would be as follows:
setup 10 10 0.75
The list of commands supported by the myVelib CLI must include the following ones:
setup <velibnetworkName>
: to create a myVelib network with given name andsetup <name> <nstations> <nslots> <s> <nbicycles>
: to create a myVelib net-addUser <userName,cardType, velibnetworkName>
: to add a user with nameoffline <velibnetworkName, stationID>
: to put oine the station stationIDonline <velibnetworkName, stationID>
: to put online the station stationID ofrentBicycle <userID, stationID>
: to let the user userID renting a bicycle from stationreturnBicycle <userID, stationID, time>
: to let the user userID returning a bicycledisplayStation<velibnetworkName, stationID>
: to display the statistics (as ofdisplayUser<velibnetworkName, userID>
: to display the statistics (as of Sec-sortStation<velibnetworkName, sortpolicy>
: to display the stations in increas-[x] display <velibnetworkName>
: to display the entire status (stations, parking bays,
users) of an a myVelib network velibnetworkName.
[x] to be completed … (the help command and exit command)
It should be possible to write those commands on the CLUI and to run the com-
mands in an interactive way: the program read the commands from testScenarioN.txt
(see Section 4.2), pass them on to the CLUI, and store the corresponding output to
testScenarioNoutput.txt.
syntax errors while typing in a command, and misuse errors, like for example trying to
rent a bicycle from a station which is oine or that has no available bicycles.
In order to evaluate your implementations we (the Testers of your project) require you (the
Developers) to equip your projects with both standard Junit tests (for each class) and
a test scenario, described below. Both JUnit tests and the test scenario are mandatory
parts of your project realisations, as we (the Testers) will resort to both of them to test
your implementations.
Each class in your project must contain JUnit tests for the most significant methods (i.e.
excluded getters and setters).Hint
: if you follow a Test Driven Development
approach you will end up naturally having
all JUnit tests for all of your classes.
In order to test your solution you are required to include in the project
Configuration file
: An initial configuration file must ensure that, at startup (after loading this file) the system contains at leas the \standard” setup corresponding to the default
version of the CLI command setup.
Test-scenario file
: A test-scenario file contains a number of CLUI commands whose
execution allows for reproducing a given test scenario, typically setting up a given config-
uration of the myvelib system (i.e. creation of some velib network, adding of some users,
simulation of some rental/returning of bicycles, simulation of planning of a ride, computation
of statistics for the stations and the users, etc.). You may include several test-scenario
files (e.g. testScenario1.txt, testScenario2.txt, …). For each test-scenario file you
provide us with you MUST include a description of its content (what does it test?) in the
report. We are going to run each test-scenario file through the runtest command of the
CLUI (see CLUI commands above):
runTest testScenario1.txt