Explanation of Solution
Given: The project name music-organizer-v1 and the class name MusicOrganizer.
To find: The way to store the names of some audio files and the number of files returned by the numberOfFiles.
Solution:
Open BlueJ and then open a new project named Music-organizer-v1.
To make the instance of the class MusicOrganizer:
Right-click on the class MusicOrganizer.
Select construct new MusicOrganizer() of the class MusicOrganizer to make its instance.
A window would show up which will ask for the name of the instance.
So, enter the name of the instance as objMusicOrg1 in place of default instance name and click on OK button.
After that, right-click on that instance residing on the object bench and then click on the method addFile to add some file names to the instance.
A window would show up asking for the name of the file to add it to the collection.
Enter any file name (along with its location) within the text box linked with it and then click on the OK button.
Repeat this procedure two times to add two file names to the collection.
To examine the number of files stored, right-click on the instance objMusicOrg1 of the class MusicOrganizer and then click on the method getNumberOfFiles.
As we have added two files to the collection, the method result of getNumberOfFiles returned 2.
To print the files stored in the collection of the class instance objMusicOrg1, we require to method call listFile.
When the method listFile is called, a window would show up which will ask for the file index. Since we have stored 2 files in the collection and the indexing in any collection starts form 0, starting from 0 the index will end at 1, that is, from 0 to 1.
Here, 0 shows the first file index and 1 shows the second file index.
Output:
After clicking on the OK button in the window shown above, we get the following result.
Modifying the index at the time of calling the method listFile, we get the filenames stored in that index on the Terminal Window.
Want to see more full solutions like this?
Chapter 4 Solutions
Objects First with Java: A Practical Introduction Using BlueJ (6th Edition)
- In Java please. Add comments as well. Thank you!arrow_forwardWrite assignments to the library, cs101, and track variables (which you defined in the previous three exercises) to create the appropriate ArrayList objects. Write them once using diamond notation and once without diamond notation, specifying the full type.arrow_forwardYour task: Remove any word that does not start with a capital letter. For instance, for the input text of "Hello, 2022 world!", we should get "Hello, 2022 !".arrow_forward
- In your workshop project create a new Java class (BasicArrayList) and convert the above code to work for ArrayLists. 1. You will need to import at least one package, but you do not need to import java.lang, which is the fundamental Java package (the classes you automatically get when you write Java programs). 2. Convert the first for-loop first. Don't forget you cannot use the ArrayList method to control the for-loop (so just use the number 4). 3. Convert the last for-loop next, to view the contents of your ArrayList. 4. Convert the middle for-loop last. You may want to convert the one line of array code to two lines of ArrayList code. 5. Finally, before the last for-loop, add a new element (0) to position 0 of the ArrayList. You should print the contents of the modified ArrayList. Here is a quick review of how array elements are modified and accessed: 1. public class BasicArray{ 2. public static void main(String[] args) int[] basic = new int[4]; for (int i=0; iarrow_forwardIn this project, you are going to introduce a Netflix-like (or Amazon prime video/Hulu/Apple+/Disney+) menu, composed by categories, each of which consists of a list of movies. Namely, there are a number of rows. For each row, users can browse movies in a circular way. For all rows/categories, users could browse up and down but not in a circular way. With the above background, please implement a Netflix-like menu using (1) DLL for connecting the beginning of all rows/categories; (2) each row/category is constructed by a CLL. A possible illustration of the above concepts is shown at the end of the file. Note that there is more than one way to implement the relationship between DLL and CLLS here (and the header of a CLL is not shown here because of a variety of possible implementations. You are required to introduce a header for each CLL). For the entire Netflix, here are the features included: a. Add a new category by name (e.g., void addCategory(string name)) b. Search a category by…arrow_forwardThis is a sample data in my JSON file: {"firstName": "Juan","middleName": "Dela","lastName": "Cruz","username": "Juan111","password": "1234"} Please make a JAVA GUI code that will display all the array lists (please make an iterator) in my JSON file. Please make it similar to the image. For each user, please add an "accept" and "reject" option. This will allow the server to decide whether or not to accept the client to the application. You do not have to code the acceptance of the client, just add the buttons, I will be the one to continue the code.arrow_forwardPlease help me create a cave class for a Hunt the Wumpus game (in java). You can read the rules in it's entirety of the Hunt the Wumpus game online to get a better idea of the specifications. It's an actual game. INFORMATION: The object of this game is to find and kill the Wumpus within a minimum number of moves, before you get exhausted or run out of arrows. There is only one way to win: you must discover which room the Wumpus is hiding in and kill it by shooting an arrow into that room from an adjacent room. The Cave The Wumpus lives in a cave of 30 rooms. The rooms are hexagonal. Each room has up to 3 tunnels, allowing access to 1, 2 or 3 (out of 6) adjacent rooms. The attached diagram shows the layout of rooms in the cave. The map wraps around such that rooms on the edges (white cells) have neighbors from the opposite edge (blue cells). E.g., the neighbors of room 1 are rooms 25, 26, 2, 7, 6, and 30, and you could choose to connect room 1 to any of these rooms. Observe how…arrow_forwardUpdate it to create a class Student that includes four properties: an id (type Integer), a name (type String), a Major (type String) and a Grade (type Double). Use class Student to create objects (using buttonAdd) that will be read from the TextFields then save it into an ArrayList. Perform the following queries on the ArrayList of Student objects and show the results on the listViewStudents (Hint: add buttons as needed): d) Use lambdas and streams to calculate the total average of all Students grades, then show the result. e) Use lambdas and streams to group Students by major, then show the results. 1. Ch3HW; import javafx.application.Application; import javafx.fxml.FXMLLoader; import javafx.scene.Parent; import javafx.scene.Scene; import javafx.stage.Stage; public class MainApp extends Application{ @Override publicvoidstart(StageprimaryStage) throwsException { FXMLLoader loader…arrow_forwardUpdate it to create a class Student that includes four properties: an id (type Integer), a name (type String), a Major (type String) and a Grade (type Double). Use class Student to create objects (using buttonAdd) that will be read from the TextFields then save it into an ArrayList. Perform the following queries on the ArrayList of Student objects and show the results on the listViewStudents (Hint: add buttons as needed): d) Use lambdas and streams to calculate the total average of all Students grades, then show the result. 1. Ch3HW; import javafx.application.Application; import javafx.fxml.FXMLLoader; import javafx.scene.Parent; import javafx.scene.Scene; import javafx.stage.Stage; public class MainApp extends Application{ @Override publicvoidstart(StageprimaryStage) throwsException { FXMLLoader loader =newFXMLLoader(getClass().getResource("StudentScreen.fxml")); Parent parent = loader.load(); Scene scene =newScene(parent);…arrow_forwardplease answerarrow_forwardI need help creating the printAnimal() method that prints from the menu, I keep getting errors and I cannot figure out what I am doing wrong. I have included pictures of the first part of the menu loop and the print menu implement a printAnimals() method that provides easy-to-read output displaying the details of objects in an ArrayList. To demonstrate this criterion in a “proficient” way, your implemented method must successfully print the ArrayList of dogs or the ArrayList of monkeys. To demonstrate this criterion in an “exemplary” way, your implemented method must successfully print a list of all animals that are “in service” and “available”. This is what I have so far for the method: // Complete printAnimals // Include the animal name, status, acquisition country and if the animal is reserved. // Remember that this method connects to three different menu items. // The printAnimals() method has three different outputs // based on the listType parameter…arrow_forwardPlease answer the question in the screenshot. The language used is Java.arrow_forwardarrow_back_iosSEE MORE QUESTIONSarrow_forward_ios
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education