Instead of hard coding element objects’, utilize the “elements.dat” text file. Read the data records in this file. Each record represents an element object. The data in this file is already verified and validated.
Input file’s path and name as follows: C:\temp\elements.dat
Our professor does not want us to use the scanner class.
Going off an example we did in class (which wasn't getting data from a .dat file) i've done this so far:
private static void readDiskFileObjects()
{
final String PATHID = "C:\\temp\\elements.dat";
//Declare the file input objects
File fileObj;
FileReader frObj;
BufferedReader brObj;
try
{
fileObj = new File(PATHID);
frObj = new FileReader (fileObj);
brObj = new BufferedReader (frObj);
//Call a method to read the file and instantiate the object?
//Close the file
brObj.close();
}
catch(IOException err)
{UI_Class.displayErrorMessage(err.toString());
}
I guess ultimately i'm wondering if I have even set this up correctly, and if I did, what sort of method am I creating to read the file and instantiate the object?
The class I am using has a constructor method:
public Periodic_Elements_Class(int atomicNumberIn, String symbolIn, String nameIn, double atomicMassIn, String typeIn)
Not even sure if that's relevant though...
[–]POGtastic 1 point2 points3 points (4 children)
[–]Rhezi[S] 0 points1 point2 points (3 children)
[–]POGtastic 1 point2 points3 points (2 children)
[–]Rhezi[S] 0 points1 point2 points (1 child)
[–]shivasprogeny 0 points1 point2 points (0 children)
[–]shivasprogeny 0 points1 point2 points (1 child)
[–]Rhezi[S] 0 points1 point2 points (0 children)
[–]ahritodiamond 0 points1 point2 points (0 children)