Question
Java question with interface and classes How do I: IReadDataFile interface Create interface IReadDataFile Add method signature: populateData with no return type and an empty
Java question with interface and classes
How do I:
IReadDataFile interface | Create interface IReadDataFile |
| Add method signature: populateData with no return type and an empty parameter list |
ReadDataFile class | Update the class so that it implements interface IReadDataFile TIP: Use Netbeans right click menu, Insert Code, Implement Method to have the IDE generate the methods for you; you will replace the throw exception statements with the source code you write Add member variables using the specified data types:Scanner // for reading the file String // for storing the file name ArrayList of class String // for storing the data from the file TIP: member variables should have an access level modifier of private to protect the data Add a custom constructor that receives one parameter of type String representing the name of the data file to read; it should do the following:Set the member variable of type String for storing the file name equal to the parameter Instantiate the member variable of type ArrayList Add a getter for the ArrayList member variable that stores the data read from the data fileTIP: Use the IDE right click menu, Refactor, Encapsulate Fields and select just getter for the member variable of focus Implement method populateData; it should do the following:Instantiate an instance of Java API class URL passing as an argument member variable representing the file name of the data fileTIP: this is a unique implementation, to instantiate the instance set the URL variable equal to static method call getClass().getResource() Instantiate an instance of class File using the URL created above Initialize member variable of type Scanner based on the File instance created aboveTIP: pass as an argument to the constructor the reference object of the URL instance with method call .toURI() Loop through the data file until the endAdd to the ArrayList representing the data in the file each value read from the data file |
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