Python code for simple Vending Machine simulation ... | Vending machine Python

The project simulates a vending machine dispensing drinks for customers for X hours (user input), given that arrival times follow a Poisson(K) ...CodeReviewStackExchangeisaquestionandanswersiteforpeerprogrammercodereviews.Itonlytakesaminutetosignup.SignuptojointhiscommunityAnybodycanaskaquestionAnybodycananswerThebestanswersarevotedupandrisetothetopHomePublicQuestionsTagsUsersUnansweredFindaJobJobsCompaniesTeamsStackOverflowforTeams–Collaborateandshareknowledgewithaprivategroup.CreateafreeTeamWhatisTeams?TeamsCreatefreeTeamTeamsQ&AforworkConnectandshareknowledgewithinasinglelocationthatisstructuredandeasytosearch.LearnmorePythoncodeforsimpleVendingMachinesimulationimplementingOOPprinciplesAskQuestionAsked8monthsagoActive8monthsagoViewed1ktimes2\$\begingroup\$IamrecentlylearningOOPconceptsandthoughtthatimplementingasimpleworkflowsimulatingavendingmachinewouldhelpmeputwhatI'velearntintopractice.Iamopentocriticismsandfeedback,andammainlytryingtogetsomecommentsregarding:BestpracticesforOOPFilestructureDataencapsulationUnittestingpracticesGeneralarchitectureadviceforOOPTheprojectsimulatesavendingmachinedispensingdrinksforcustomersforXhours(userinput),giventhatarrivaltimesfollowaPoisson(K)distributionandaninitialstocklist(userinput).Theprojectalsoproducesasalesreportforthegivensimulation.Thelinktomytheentiregithubrepositoryishere:https://github.com/jtsw1990/oop_vending_machineBelowisasnippetofvending_machine.py,whichistheclasstosimulatethebehaviorofatypicalvendingmachine.Anyhelpisappreciatednotjustforthissnippet,buttheotherclassesintherepoaswelllikethecustomerclass.importcsvimportnumpyasnpclassDataReader:'''ObjecttoreadininitialdrinksdatasettobeusedasinputinVendingMachineclass'''def__init__(self,filepath):self.df=[]withopen(filepath,"r")asfile:my_reader=csv.reader(file,delimiter=",")next(my_reader)forrowinmy_reader:self.df.append(row)classVendingMachine:'''Insertdocstringhere'''def__init__(self,max_capacity):print("__init__isbeingcalledhere")self.max_capacity=max_capacity


常見投資理財問答


延伸文章資訊