it isnt printing the address number |
And… do you plane to share your output with us over the next few days? :-)
(Ok, just joking)
Please, consider that the loop inside my version of getFile() (BTW, perhaps getData() would be a better name) expects every line to have got the same number of ‘fields’; it later discards the unused one if it’s creating an instance of “Residential” (other note: name of classes usually are taken from nouns, not from adjectives, because it helps considering them as types, which is what they are).
You can see in my last post I’ve modified the input file forcing every line to have the same length (in terms of amount of fields).
If you decided to add a method for writing data into you classes, of course “Residential” could not add that extra field, since it can’t be aware of its ‘offspring’.
In that case it could make sense to change the mentioned reading loops to make it evaluate how many fields it should read according to the first one it meets (“Residential” versus “Commercial”).
If using my version of your data file doesn’t solve your issue, just post again – there are likely to be hundres of bugs on my code, I wrote it quickly, just to make it work. But try to put yourself in the reader’s shoes, if you can. The day you’re happy with your code, please consider ticking the post as solved.