Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

COLLECTIONS (2 Assignments: Text version and GUI version) This program will give you more practice with Collections. Make sure to download the data file (fruit.txt)

COLLECTIONS (2 Assignments: Text version and GUI version)

This program will give you more practice with Collections. Make sure to download the data file (fruit.txt) and the zip file (fruitImages.zip) from our website to the dame folder as your program. The fruit.txt file contains fruit names and nutritional values (vitamin content). FruitImages.zip file contains images of the fruits. You may use ArrayLists to save the data into your memory. Your program should choose one of the fruits at random, using the random method and display the name spelled randomly, by using Collections.shuffle. The program will have a text area for the user to enter their guess of which fruit is being displayed. If the guess was right the fruit image should appear and the fruits nutritional values. There will be a start button that will shuffle the fruit names for the user and when the user enters their guess the program should move on to the next shuffled fruit name.

This is a kind of puzzle games that uses the same concepts of Abstract class as the previous assignment. Since this is a game the users response should be timed and that time should be displayed along with the fruit image and the nutritional values.

-----fruit.txt--------

BANANA APPLE ORANGE GRAPE APRICOT MANGO COCONUT CHERRY RASPBERRY LEMON

-------------------------------------

This program should consist of many different methods and the main should only have a call to the frame of the GUI in it.

First the frame should be created with all the private and public variables that will be used. Variables for the width and height of both the frame and the images of the fruit, which should all be the same size. Variables for fruit labels, fruit data, string variables for the fruit names and the users answers, and a button to start the whole process. A hashmap should be used to connect the string fruit names with their images in the zip file. (This is very important)

The frame class should also include the constructor which will have all the calls to the other methods in it.

One to fill the map One to read the fruit names and add them to a list. One to be the main frame which will set everything up to be displayed. Make sure to add the panel where all the information in displayed to the frame then add everything you want displayed to the panel. Set frame visibility to true.

Create and define each method.

A method to read and add fruit names. A method to get one of the fruit names at random. A method to shuffle the single letters of each fruit name the last method gets. A method to take which ever fruit name was chosen and connect it the .png, then display that image at the appropriate size and location. A method to fill the hashmap with the appropriate information. Finally a method to extend JPanel and create your own panel which can receive the fruit images.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Machine Learning And Knowledge Discovery In Databases European Conference Ecml Pkdd 2010 Barcelona Spain September 2010 Proceedings Part 3 Lnai 6323

Authors: Jose L. Balcazar ,Francesco Bonchi ,Aristides Gionis ,Michele Sebag

2010th Edition

3642159389, 978-3642159381

More Books

Students also viewed these Databases questions

Question

Philip Crosby said that quality is free. Why?

Answered: 1 week ago