Question
This project we will read in the beers file, with try catch blocks into an arrayList, will will be able to display the contents of
This project we will read in the beers file, with try catch blocks into an arrayList, will will be able to display the contents of the file as an output. We will be able to search the arraylist multiple times until we determine to quit searching. You will need to complete the methods provided. Also, you will need create a method which contains a loop which calls the search function. You will need some flag which will end the loop.
Make sure your code is well commented (-10) if not. No comments minus 20. Please Zip your project, only zipped projects will be accepted. Please submit the entire project and all folders and sub-folders and files.
Additional Information:
It seems some of you were struggling with pulling the arraylist from a file conceptually. However, here is an example for you. Create a file called values.txt, Add some rows of whatever (favorite song lyrics). Have java read the file and display it. Then add in the code to post the read line into an arraylist. Remember you have to break this down into small parts. each step, no leaps. Computers do not leap. Next add in the try cartch blocks or add them in first (you will have to live with your choices.). Thinking in small steps, you type one character at a time, you do not type a paper, you type one character at a time, you save it multiple times by moving the mouse over the save button and pressing it. Think of the small steps you need to take.
File file = new File ("Values.txt");
Scanner inputFile = new Scanner(file);
while (inputFile.hasNext() )
{
msg = inputFile.nextLine();
System.out.println(msg);
myArrayList.add(msg);
}
beers.txt
public class BeerAnyone { private static ArrayList beerList; /** * @param args */ public static void main(String[] args) { // TODO Auto-generated method stub // declare the arraylist which will contain a list of beers. //ArrayList beerList; // use generic read file array list to set file contents to an array list. // read file and get list of beers into an array list. beerList = readFileArrayList("beerlist.txt"); // print the array list. printArrayList(beerList);
// code to call the loop for searching the arraylist. The search method will be called from the method you name and create. It will call the search method.
} // end main /** * printArrayList * takes an array list and prints it to the console * @param theArrayList */ private static void printArrayList(ArrayList theArrayList)
} // printArrayList /** * readFileArrayList * read from the file beer names into a list array and return the arraylist. * @return */ private static ArrayList readFileArrayList(String fileName) {}
/** * printArrayList * search the arrayList for the term in the parameter and returns the entire row. * @param searchTerm */ private static String search(String searchTerm){ }
}
as a beers text :
1. Good Morning Tree House Brewing Company American Double /
Imperial Stout / 8.40% ABV 4.72 190 | 896
2. Mornin' Delight Toppling Goliath Brewing Company American Double /
Imperial Stout / 12.00% ABV 4.68 129 | 763
3. Kentucky Brunch Brand Stout Toppling Goliath Brewing Company
American Double / Imperial Stout / 12.00% ABV 4.68 76 | 480
4. Pliny The YoungerRussian River Brewing Company American Double /
Imperial IPA / 11.00% ABV 4.66 891 | 2,784
5. Heady Topper The Alchemist American Double / Imperial IPA /
8.00% ABV 4.66 2,124 | 11,853
6. Dinner Maine Beer Company American Double / Imperial IPA /
8.20% ABV 4.64 173 | 1,480
7. Founders CBS Imperial Stout Founders Brewing Company American
Double / Imperial Stout / 10.60% ABV 4.62 959 | 4,055
8. Bourbon Barrel Aged Vanilla Bean Dark Lord 3 Floyds Brewing Co.
Russian Imperial Stout / 15.00% ABV 4.61 269 | 1,329
9. Trappist Westvleteren 12 (XII) Brouwerij Westvleteren (Sint-
Sixtusabdij van Westvleteren) Quadrupel (Quad) / 10.20% ABV 4.6
1,767 | 5,819
10. Julius Tree House Brewing Company American IPA / 6.80% ABV
4.6 330 | 2,300
11. King Julius Tree House Brewing Company American Double / Imperial
IPA / 8.30% ABV 4.6 60 | 286
12. Pliny The Elder Russian River Brewing Company American Double /
Imperial IPA / 8.00% ABV 4.6 3,502 | 13,328
13. Bourbon County Brand Coffee Stout Goose Island Beer Co. American
Double / Imperial Stout / 13.40% ABV 4.58 1,105 | 6,577
14. Barrel-Aged Abraxas Perennial Artisan Ales American Double /
Imperial Stout / 11.00% ABV 4.57 99 | 1,122
15. Juice Machine Tree House Brewing Company American Double /
Imperial IPA / 8.20% ABV 4.57 56 | 210
16. Fundamental Observation Bottle Logic Brewing American Double /
Imperial Stout / 14.30% ABV 4.56 73 | 325
17. Rare Bourbon County Brand Stout (2015) Goose Island Beer Co.
American Double / Imperial Stout / 14.50% ABV 4.56 77 | 453
18. Focal Banger The Alchemist American IPA / 7.00% ABV 4.56
167 | 1,732
19. Sip Of Sunshine Lawson's Finest Liquids American Double /
Imperial IPA / 8.00% ABV 4.56 387 | 3,442
20. Founders KBS (Kentucky Breakfast Stout) Founders Brewing Company
American Double / Imperial Stout / 11.20% ABV 4.56 2,844 | 11,033
21. Abner Hill Farmstead Brewery American Double / Imperial IPA / 8.20%
ABV 4.56 355 | 2,357
22. King Sue Toppling Goliath Brewing Company American Double /
Imperial IPA / 8.00% ABV 4.55 121 | 1,222
23. Citra Double IPA Kern River Brewing Company American Double /
Imperial IPA / 8.00% ABV 4.55 371 | 1,567
24. Double Sunshine IPA Lawson's Finest Liquids American Double /
Imperial IPA / 8.00% ABV 4.54 322 | 1,990
25. Green Tree House Brewing Company American IPA / 7.60% ABV 4.54
179 | 1,278
26. Artaic Trillium Brewing Company American Double / Imperial
IPA / 8.50% ABV 4.54 83 | 586
27. Morning Wood Funky Buddha Brewery American Porter / 12.00% ABV
4.54 57 | 328
28. Zombie Dust 3 Floyds Brewing Co. American Pale Ale (APA) / 6.20%
ABV 4.53 1,404 | 9,136
29. Parabola Firestone Walker Brewing Co. Russian Imperial Stout /
14.00% ABV 4.53 1,106 | 5,812
30. Triple Sunshine IPA Lawson's Finest Liquids American Double /
Imperial IPA / 10.50% ABV 4.52 49 | 512
31. Ann Hill Farmstead Brewery Saison / Farmhouse Ale / 6.50% ABV4.52
65 | 267
32. PseudoSue Toppling Goliath Brewing Company American Pale Ale
(APA) / 5.80% ABV 4.51 425 | 3,303
33. Double Galaxy Hill Farmstead Brewery American Double / Imperial
IPA / 8.00% ABV 4.51 181 | 1,034
34. Cantillon Fou' Foune Brasserie Cantillon Lambic - Fruit / 5.00%
ABV 4.5 493 | 2,554
35. Duck Duck Gooze The Lost Abbey American Wild Ale / 7.00% ABV
4.5 260 | 1,556
36. Hunahpu's Imperial Stout Cigar City Brewing American Double /
Imperial Stout / 11.00% ABV 4.5 717 | 3,622
37. Bourbon County Brand Stout Goose Island Beer Co. American Double /
Imperial Stout / 13.80% ABV 4.5 2,759 | 11,321
38. Society & Solitude #4 Hill Farmstead Brewery American Double /
Imperial IPA / 8.00% ABV 4.5 124 | 888
39. Supplication Russian River Brewing Company American Wild Ale
/ 7.00% ABV 4.49 1,404 | 5,854
40. Resolute - Coconut Brothers Craft Brewing American Double /
Imperial Stout / 13.50% ABV 4.49 38 | 83
41. In Perpetuity Tree House Brewing Company American IPA / 6.70%
ABV 4.49 62 | 275
42. Alter Ego Tree House Brewing Company American IPA / 6.80% ABV
4.49 126 | 856
43. Cantillon Blbr Lambik Brasserie Cantillon Lambic - Fruit /
5.00% ABV 4.49 230 | 685
44. Bell's Black Note Stout Bell's Brewery, Inc. American Double /
Imperial Stout / 11.40% ABV 4.49 563 | 3,790
45. Galaxy Dry Hopped Fort Point Pale Ale Trillium Brewing Company
American Pale Ale (APA) / 6.60% ABV 4.49 92 | 885
46. The Abyss Deschutes BreweryAmerican Double / Imperial Stout /
12.20% ABV 4.49 1,831 | 6,395
47. Ephraim Hill Farmstead Brewery American Double / Imperial IPA /
10.50% ABV 4.48 209 | 879
48. Kuhnhenn Bourbon Barrel Fourth Dementia Kuhnhenn Brewing Company
Old Ale / 13.50% ABV 4.48 392 | 1,793
49. Double Citra Hill Farmstead Brewery American Double / Imperial
IPA / 8.00% ABV 4.48 183 | 1,521
50. Bourbon Barrel Aged Dark Lord Imperial Stout 3 Floyds Brewing Co.
Russian Imperial Stout / 15.00% ABV 4.48 182 | 705
I need help to write this project in java coding.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started