Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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 file

TIP: 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 file

TIP: 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 above

TIP: 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 end

Add 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

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

Database And Expert Systems Applications 19th International Conference Dexa 2008 Turin Italy September 2008 Proceedings Lncs 5181

Authors: Sourav S. Bhowmick ,Josef Kung ,Roland Wagner

2008th Edition

3540856536, 978-3540856535

More Books

Students also viewed these Databases questions

Question

2. How much time should be allocated to the focus group?

Answered: 1 week ago

Question

1. Where will you recommend that she hold the focus group?

Answered: 1 week ago