java question and need the explanation and answer to help me learn.
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.
Requirements: just as long as the code works
Assignment#3CSCI201Fall20236.0%ofCourseGradeTitleJoesTablev2.0TopicsCoveredNetworkingMulti-ThreadingConcurrencyIssuesAPIQueryingIntroductionAfterastressfulandsweatypitch,theCouncilofSALissatisfiedwithyourorder-schedulingprototypedemoapplicationandhasunanimouslydecidedtogiveyouthegreenlighttofullyimplementyourapplication.ThisinvolvespullingrealdatafromYelp,issuingordersfromJoesTableHQtodriversinrealtimeoverthenetwork,andchainingordersfordrivers,muchlikesomeotherfooddeliveryapplicationwhosenameshallnotbementioned.Asuccessfulimplementationwillgainyou5pointsandpossiblyagoodwordfromthedirector.YelpAPIInadditiontoreadingindatafromahard-codedtextfile,youwillusetheYelpAPItoretrieverestaurantdata.Inotherwords,therestaurantdata(i.e.,address,coordinates,etc.)shouldnowbepulledfromthisAPI,andyouwillonlyhavetoreadfromtheCSVfileforthescheduleoforders.YoucanlearnmoreabouttheYelpAPIhere:https://docs.developer.yelp.com/docs/fusion-intro.ThedatawillbereturnedinJSONformat.Pleasekeepinmindthatthereisalimitof5,000APIcallsperday,sodonotwaittostartyourassignmentuntilthelastday.YouwillalsoneedtogenerateanAPIKey,sostarttheassignmentearlytoallowenoughtimefortesting.AssignmentInthisassignment,youwillcreatetwodifferentprograms-aserverandaclient.Youwillimplementanetworkeddeliverysystemwhereclients(whichrepresentdrivers)receiveordersfromtheserver(whichrepresentstheheadquarters),andthedriverswilldelivertheorderstotheappropriaterestaurants.Ifitseemscounterintuitive,youcanthinkofitasabackwardsfooddeliverysystem,wherefoodisdeliveredtorestaurants.Alternatively,yourdriversaredeliveringingredientsfortheorderstotherestaurants.Therewillbesomeconcurrencyissuessincedriverswillhavetowaitonotherdriversbeforestartingthedelivery.Therewillbemanywaystodesignouttheprogram,soitwouldbewisetospendsometimedesigningtheprogrambeforeyoubegincoding.Similartothepreviousassignment,hereisasampleschedule.csvfile:
0,MomotaRamenHouse,blackgarlicramen0,MomotaRamenHouse,spicymisoramen0,Slurpin’RamenBar,veggieramen3,DaikokuyaLittleTokyo,daikokuramen3,DaikokuyaLittleTokyo,daikokuramen9,DaikokuyaLittleTokyo,daikokuramen9,IkiRamen,shoyuramen10,IkiRamen,yuzushioramenServerFunctionalityWhenyourserverfirstruns,prompttheuserforthenameoftheschedulefileandfortheircoordinates(similartothepreviousassignment).Thiswillbethe“home”locationthatdriverswillleavefromandreturnto.Then,theservershouldasktheuserhowmanydriverswillbedispatched.Forexample,iftheuserenters“3,”thatmeanstheserverwillnotsendoutanyordersuntil3clients(akadrivers)haveconnectedtotheserver.Afterwards,theservershouldbeginlisteningonport3456forclientconnections.Everytimeaclientconnectstotheserver,verifythattheconnectionwasmadebyprintinganoutputfromtheserver,likethesampleoutputbelow.ClientFunctionalityTheclientwillbeginbywelcomingtheusertotheprogramandprompttheuserfortheserverhostnameandport.Ifavalidconnectionismade,theprogramshouldlettheuserknowhowmanymoredriversareneededbeforetheordersaredelivered.Forexample,ifthereiscurrentlyonly1connection,theclientshouldprintamessagesayingthat2moredriversareneededbeforetheorderscanbedelivered.Thisnumbershouldbeinclusive,suchthatthetotalnumberofconnecteddriversincludesthecurrentdriveraswell.Oncetheordersaredispatched,theclientwillberesponsiblefordeliveringtheordertotheappropriaterestaurants.TheclientshouldalsobehandlingthereturneddatafromtheAPIcallstodeterminethedistancesofeachrestaurantfromthecurrentposition.ProgramExecutionUnliketheprevioushomeworkassignment,driverscandelivermorethanoneorderatatime.Additionally,driverscandeliverorderstomultiplerestaurantsatatime.Driverswilldeliverorderswiththeshortestdistancefirst.So,onceanorderisdelivered,thedriverwillneedtorecalibratethedistancefromtheircurrentlocationtothenextlocationandpicktheshortestdistanceagain.Thisiscontinueduntiltherearenomoreorders,inwhichcasethedriverwillreturntothe“home”locationthatwasprovidedwhentheserverfirstexecuted.Adrivershouldhandleasmanyordersaspossibleatthemomentofdispatch.Thismeansthatifthereare5ordersthatallhavethesametimestamp,onedrivershouldberesponsibleforall5orders.Similarly,ifonly1orderisreadyatatimestamp,thedrivershouldonlydeliver1order.Ifthereareavailabledrivers,ordersshouldbedeliveredpromptly.Iftherearenoavailabledrivers,theorderwillremaininthe
queueuntiladriverreturnsfromtheirdelivery.Onceadriverreturns,thedrivershouldpickupallofthequeuedorders(withrespecttothecurrenttime).Additionally,pleasekeepinmindthatyouwillnotneedtodoublethedistanceforeachdelivery.Inthepreviousassignment,everydeliverywasround-trip;however,thisconditioncannotbeguaranteedifadriverhandlesmultipleorderstodifferentrestaurantsatatime.Yourprogramshouldprintuponcompletingthedeliverytoarestaurant,andsleepaccordingtothecalculateddistancebetweenpoints.Assuch,pleasefollowthesampleexecutionbelowfortheproperoutput.SampleExecutionBelowisasampleexecutionoftheprogram.Thetimestamphasbeenboldedtomakeiteasiertoreadforthissampleoutput.ServerClient1Client2Whatisthenameoftheschedulefile?missing.csvThatfiledoesnotexist.Whatisthenameoftheschedulefile?badformat.csvThatfileisnotproperlyformatted.Whatisthenameoftheschedulefile?schedule.csvWhatisyourlatitude?34.02116Whatisyourlongitude?-118.287132Howmanydriverswillbeinservicetoday?2Listeningonport
3456.Waitingfordrivers…Connectionfrom127.0.0.1Waitingfor1moredriver(s)…Connectionfrom127.0.0.1Startingservice.WelcometoJoesTablev2.0!Entertheserverhostname:localhostEntertheserverport:34561moredriverisneededbeforetheservicecanbegin.Waiting…Alldrivershavearrived!Startingservice.[00:00:00.000]StartingdeliveryofblackgarlicramentoMomotaRamenHouse.[00:00:00.002]StartingdeliveryofspicymisoramentoMomotaRamenHouse.[00:00:00.002]StartingdeliveryofveggieramentoSlurpin’RamenBar.[00:00:00.567]FinisheddeliveryofblackgarlicramentoMomotaRamenHouse.[00:00:00.567]FinisheddeliveryofspicymisoramentoMomotaRamenHouse.WelcometoJoesTablev2.0!Entertheserverhostname:localhostEntertheserverport:3456Alldrivershavearrived!Startingservice.
[00:00:00.567]ContinuingdeliverytoSlurpin’RamenBar.[00:00:03.349]FinisheddeliveryofveggieramentoSlurpin’RamenBar.[00:00:03.349]Finishedalldeliveries,returningbacktoHQ.[00:00:06.095]ReturnedtoHQ.[00:00:08.956]StartingdeliveryofdaikokuramentoDaikokuyaLittleTokyo.[00:00:08.956]StartingdeliveryofshoyuramentoIkiRamen.[00:00:00.000]StartingdeliveryofdaikokuramentoDaikokuyaLittleTokyo.[00:00:00.003]StartingdeliveryofdaikokuramentoDaikokuyaLittleTokyo.[00:00:03.358]FinisheddeliveryofdaikokuramentoDaikokuyaLittleTokyo.[00:00:03.358]FinisheddeliveryofdaikokuramentoDaikokuyaLittleTokyo.[00:00:03.358]Finishedalldeliveries,returningbacktoHQ.[00:00:06.710]ReturnedtoHQ.
Allorderscompleted![00:00:11.818]FinisheddeliveryofshoyuramentoIkiRamen.[00:00:11.818]ContinuingdeliverytoDaikokuyaLittleTokyo.[00:00:15.795]FinisheddeliveryofdaikokuramentoDaikokuyaLittleTokyo.[00:00:15.795]Finishedalldeliveries,returningbacktoHQ.[00:00:19.147]ReturnedtoHQ.[00:00:19.191]Allorderscompleted![00:00:06.995]StartingdeliveryofyuzushioramentoIkiRamen.[00:00:09.856]FinisheddeliveryofyuzushioramentoIkiRamen.[00:00:09.856]Finishedalldeliveries,returningbacktoHQ.[00:00:12.715]ReturnedtoHQ.[00:00:19.191]Allorderscompleted!
GradingCriteriaThewayyougoaboutimplementingthesolutionisnotspecificallygraded,buttheoutputmustmatchexactlywhatyouseeintheexecutionabove.Themaximumnumberofpointsearnedis5.Networking(1.0)0.2Thefirstclientcanconnecttotheserver0.3Onlythenumberofclientsspecifiedcanconnecttotheserver.0.5ServeroutputiscorrectDataI/O(1.0)0.3Theschedulefileisreadappropriately0.2DataisparsedfromtheYelpAPI0.5ClientoutputiscorrectProgramExecution(3.0)1.0Theorderofdeliveriesiscorrect1.0Thetimingofdeliveriesiscorrect1.0Ordersaredeliveredasexpectedwithnoexceptions,crashing,deadlock,starvation,orfreezing.