0% found this document useful (0 votes)
103 views7 pages

Assignment #3 CSCI 201 Fall 2023 6.0% of Course Grade

Download as pdf or txt
Download as pdf or txt
Download as pdf or txt
You are on page 1/ 7

Assignment #3

CSCI 201 Fall 2023


6.0% of Course Grade
Title
JoesTable v2.0

Topics Covered
Networking
Multi-Threading
Concurrency Issues
API Querying

Introduction
After a stressful and sweaty pitch, the Council of SAL is satisfied with your
order-scheduling prototype demo application and has unanimously decided to give
you the green light to fully implement your application. This involves pulling real data
from Yelp, issuing orders from JoesTable HQ to drivers in real time over the network,
and chaining orders for drivers, much like some other food delivery application
whose name shall not be mentioned. A successful implementation will gain you 5
points and possibly a good word from the director.

Yelp API
In addition to reading in data from a hard-coded text file, you will use the Yelp API to
retrieve restaurant data. In other words, the restaurant data (i.e., address,
coordinates, etc.) should now be pulled from this API, and you will only have to read
from the CSV file for the schedule of orders. You can learn more about the Yelp API
here: https://docs.developer.yelp.com/docs/fusion-intro. The data will be returned in
JSON format.

Please keep in mind that there is a limit of 5,000 API calls per day, so do not wait to
start your assignment until the last day. You will also need to generate an API Key,
so start the assignment early to allow enough time for testing.

Assignment
In this assignment, you will create two different programs - a server and a client. You
will implement a networked delivery system where clients (which represent drivers)
receive orders from the server (which represents the headquarters), and the drivers
will deliver the orders to the appropriate restaurants. If it seems counterintuitive, you
can think of it as a backwards food delivery system, where food is delivered to
restaurants. Alternatively, your drivers are delivering ingredients for the orders to the
restaurants.

There will be some concurrency issues since drivers will have to wait on other
drivers before starting the delivery. There will be many ways to design out the
program, so it would be wise to spend some time designing the program before you
begin coding.

Similar to the previous assignment, here is a sample schedule.csv file:


0, Momota Ramen House, black garlic ramen
0, Momota Ramen House, spicy miso ramen
0, Slurpin' Ramen Bar, veggie ramen
3, Daikokuya Little Tokyo, daikoku ramen
3, Daikokuya Little Tokyo, daikoku ramen
9, Daikokuya Little Tokyo, daikoku ramen
9, Iki Ramen, shoyu ramen
10, Iki Ramen, yuzu shio ramen

Server Functionality
When your server first runs, prompt the user for the name of the schedule file and for
their coordinates (similar to the previous assignment). This will be the “home”
location that drivers will leave from and return to. Then, the server should ask the
user how many drivers will be dispatched. For example, if the user enters “3,” that
means the server will not send out any orders until 3 clients (aka drivers) have
connected to the server. Afterwards, the server should begin listening on port 3456
for client connections. Every time a client connects to the server, verify that the
connection was made by printing an output from the server, like the sample output
below.

Client Functionality
The client will begin by welcoming the user to the program and prompt the user for
the server hostname and port. If a valid connection is made, the program should let
the user know how many more drivers are needed before the orders are delivered.
For example, if there is currently only 1 connection, the client should print a message
saying that 2 more drivers are needed before the orders can be delivered. This
number should be inclusive, such that the total number of connected drivers includes
the current driver as well.

Once the orders are dispatched, the client will be responsible for delivering the order
to the appropriate restaurants. The client should also be handling the returned data
from the API calls to determine the distances of each restaurant from the current
position.

Program Execution
Unlike the previous homework assignment, drivers can deliver more than one order
at a time. Additionally, drivers can deliver orders to multiple restaurants at a time.
Drivers will deliver orders with the shortest distance first. So, once an order is
delivered, the driver will need to recalibrate the distance from their current location to
the next location and pick the shortest distance again. This is continued until there
are no more orders, in which case the driver will return to the “home” location that
was provided when the server first executed.

A driver should handle as many orders as possible at the moment of dispatch. This
means that if there are 5 orders that all have the same timestamp, one driver should
be responsible for all 5 orders. Similarly, if only 1 order is ready at a timestamp, the
driver should only deliver 1 order. If there are available drivers, orders should be
delivered promptly. If there are no available drivers, the order will remain in the
queue until a driver returns from their delivery. Once a driver returns, the driver
should pick up all of the queued orders (with respect to the current time).

Additionally, please keep in mind that you will not need to double the distance for
each delivery. In the previous assignment, every delivery was round-trip; however,
this condition cannot be guaranteed if a driver handles multiple orders to different
restaurants at a time. Your program should print upon completing the delivery to a
restaurant, and sleep according to the calculated distance between points. As such,
please follow the sample execution below for the proper output.

Sample Execution
Below is a sample execution of the program. The timestamp has been bolded to
make it easier to read for this sample output.

Server Client 1 Client 2


What is the name
of the schedule
file?
missing.csv

That file does


not exist. What
is the name of
the schedule
file?
badformat.csv

That file is not


properly
formatted. What
is the name of
the schedule
file?
schedule.csv

What is your
latitude?
34.02116

What is your
longitude?
-118.287132

How many drivers


will be in
service today?
2

Listening on port
3456.
Waiting for
drivers…
Welcome to JoesTable
v2.0!
Enter the server
hostname: localhost
Enter the server
port: 3456

Connection from 1 more driver is


127.0.0.1 needed before the
Waiting for 1 service can begin.
more driver(s)... Waiting...

Welcome to JoesTable
v2.0!
Enter the server
hostname: localhost
Enter the server
port: 3456

Connection from All drivers have All drivers have


127.0.0.1 arrived! arrived!
Starting service. Starting service. Starting service.

[00:00:00.000]
Starting delivery of
black garlic ramen
to Momota Ramen
House.
[00:00:00.002]
Starting delivery of
spicy miso ramen to
Momota Ramen House.
[00:00:00.002]
Starting delivery of
veggie ramen to
Slurpin’ Ramen Bar.

[00:00:00.567]
Finished delivery of
black garlic ramen
to Momota Ramen
House.
[00:00:00.567]
Finished delivery of
spicy miso ramen to
Momota Ramen House.
[00:00:00.567]
Continuing delivery
to Slurpin’ Ramen
Bar. [00:00:00.000]
Starting delivery of
daikoku ramen to
Daikokuya Little
Tokyo.
[00:00:00.003]
Starting delivery of
daikoku ramen to
Daikokuya Little
Tokyo.
[00:00:03.349]
Finished delivery of
veggie ramen to
Slurpin’ Ramen Bar.
[00:00:03.349]
Finished all
deliveries,
returning back to
HQ.
[00:00:06.095]
Returned to HQ. [00:00:03.358]
Finished delivery of
daikoku ramen to
Daikokuya Little
Tokyo.
[00:00:03.358]
Finished delivery of
daikoku ramen to
Daikokuya Little
Tokyo.
[00:00:03.358]
Finished all
deliveries,
returning back to
HQ.
[00:00:08.956]
Starting delivery of
daikoku ramen to
Daikokuya Little
Tokyo.
[00:00:08.956]
Starting delivery of
shoyu ramen to Iki
Ramen.

[00:00:06.710]
Returned to HQ.
[00:00:06.995]
Starting delivery of
yuzu shio ramen to
Iki Ramen.
[00:00:11.818]
Finished delivery of
shoyu ramen to Iki
Ramen.
[00:00:11.818]
Continuing delivery
to Daikokuya Little
Tokyo. [00:00:09.856]
Finished delivery of
yuzu shio ramen to
Iki Ramen.
[00:00:09.856]
Finished all
deliveries,
returning back to
HQ.
[00:00:15.795]
Finished delivery of
daikoku ramen to
Daikokuya Little
Tokyo.
[00:00:15.795]
Finished all
deliveries,
All orders returning back to
completed! HQ.
[00:00:12.715]
Returned to HQ.
[00:00:19.147]
Returned to HQ.

[00:00:19.191] All
orders completed!

[00:00:19.191] All
orders completed!
Grading Criteria
The way you go about implementing the solution is not specifically graded, but the
output must match exactly what you see in the execution above. The maximum
number of points earned is 5.

Networking (1.0)
0.2 The first client can connect to the server
0.3 Only the number of clients specified can connect to the server.
0.5 Server output is correct

Data I/O (1.0)


0.3 The schedule file is read appropriately
0.2 Data is parsed from the Yelp API
0.5 Client output is correct

Program Execution (3.0)


1.0 The order of deliveries is correct
1.0 The timing of deliveries is correct
1.0 Orders are delivered as expected with no exceptions, crashing, deadlock,
starvation, or freezing.

You might also like