Details of this Paper

Soft Drink Inventory




;;You w o rk at asoft dri n k distributorsh i pthat sells at m o st 100 differ e nt kin d s of s o ft drinks. The pro g ram youwrite for this a ssi g nment will pr oc es s w e eklytrans a c tio n sand all o w fora rep o rt to bedisplay e d that inclu d es t h e soft- dri n k na m e, ID, starti n g inventory, final in v entory, andthe numb e r of transactio n s r e ceived.;There are two data files, d ata6.txt and data6tra n s.txt,wh i c h ho l d the initial soft drink inf o rmat i on and tr a ns a ctio n s, resp e c tively.The file data 6.txt cons i s ts o fat most100 lineswh e re e ach li n e c o ntains thesoft dri n k na m e (o ne strin g), ID (string), and thesta r ting inv en tory of cases(int).;The file data 6 trans.txt hol d s the tra n s a c t ions. Each tr a ns a c t ionco ns ists of the ID followed by the numb e r of cas e s purch a s e d (p ositive integ e r), or the am o unt sold (ne g ative integer). You c an a s sume the for m at of the data is corr e c t, but not all IDs arevalid. In the case of an in v alidID, do n o t proc es s thedata (ig n ore it, no err o r m e ssag e).;Sample d a ta6.txt: Sample d a ta6trans.txt;Coke;123;100;345;10;Pepsi;345;50;123;-5;CanadaDry;678;75;345;10;DrPepper;444;120;678;8;444;20;444;-20;444;10;999;5;345;10;123;-25;The displayReport fu n c tiondispla y s the dri n k na m e, ID, s t arti n g inventory, final inventory, andthe numb e r of transacti o nspr o c e s sed. D i splay this ex a c t format (nu mberof bl a nks s e parating i tems do e s n o t have to be identical).;For the sample data,the output of your program would be as follows;Soft Drink ID Starting Inventory Final Inventory # transaction;Coke 123 100 70 2;Pepsi 345 50 80 3;CanadaDry 678 75 83 1;DrPepper 444 120 130 3;Write a SoftDrin k Inventory c la s swith the following fun c tionality;public constructor: Initializ e s arr a ys holdi n g so f tdrink n a meand ID to ho l d all empty strin g s (cal l s intitiali z eString twi c e to perform the task s). Initiali z esa r rays ho l di n g starting in v entory, final inventory, andthe c ounts of the number of transa c tion to z ero (c a l ls initiali z eInt three times to per f orm the tasks).;public buildInventory: Sets the arra y s for soft dri n k na m e, ID, andst a rti n g inventory from informati o n in the data file. The array holdingfinal inventory is set tothe same valu e sas the st a rti n g inventory.;public processTransactions: Proc e s ses the transacti o ns bycorr e c tly adjusting the fi n al inventory a nd transacti o n counts a rrays. Data for IDswh i c h d o n't exist are not proc es sed.;public displayReport: Disp l ays a report i n clud in g soft dri n k n ame,ID, star t ing inventory,final inventory, and numb e r of tr a ns a ctio n s pr o c e s sed.;private findID: Tak e s an ID par am eter andreturns the p o siti o n inthe array (the s u bscrip t) wh e re thesoft drink with that id is found. Ret u rn-1 if the ID is not found.Remem b er theid is a String (so u s e e qua l s to co m pare).;private initializeInt: Tak e s an i nt array p a r a meter a n d initializ e s all arr a y values to z e ro.;private initializeString: Tak e s a String arraypara m eter a nd initiali z e sall values to the empty String (??).;So that you are not overwhelmed with assignment 6, I have put together a skeleton SoftDrinkInventory class. This can be found in the dropbox for the assignment. All the places with "..." need you to write code.;Notice all the good comments that tell you exactly what each method does. This should both help you to write the code and teach you what a good comment looks like. Good comments let you know what the code is doing without you having to read code.;I have also provided a completed SoftDrinkTester class to be used in testing the program. This class, SoftDrinkTester, should not be modified. Be sure to read and understand this class before writing any code for the SoftDrinkInventory class.;Now here is an outline of how to attack the problem. Once you think of a large problem as a bunch of smaller ones, it becomes a much less intimidating task. Divide and conquer!;Comment out from main anything that you are not testing.


Paper#71240 | Written in 18-Jul-2015

Price : $32