CSCI 201 Fall 2023 Assignment #3
Hello, dear friend, you can consult us at any time if you have any questions, add WeChat: daixieit
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 realtime 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. Everytime 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 knowhow 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 torecalibrate 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.
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.
2023-10-31