Unit 4: Abstrat Art Issue

I am having an issue with the filer reader.

I am copying code directly from the multi selection unit and just changing the names. Even when I copy and paste code that works in from a previous lesson, it won’t work in the lesson. I am at a loss, any help would be appreciated. Super simple project below:

When i was looking through the project i did not see a FileReader.java file which is what i think the main is relying on to extract data from a project, this must be a modified distribution of the class since the original one does not have the method .toIntArray in the class perhaps this is the issue? i’m not able to fully troubleshoot if the part of the original codebase is missing

This was my fault. For some reason the “sandbox” in that lesson is not working right. Works perfectly fine in the lesson though. Not sure what is going on with that:

Same code, different spot:

perhaps this is an error on CDO’s hands, i was able to get it running by manually adding in the reader myself and compiling that way but it required a lot more configuring unfortunately so this may be an issue for support


here’s proof i got it working
https://studio.code.org/projects/javalab/x52UloeggFDwsizlbXowdPoQ4X-hmvAtaQph5qK_UOk/view
though the FileReader that was implemented must have more extended methods because the one that i was able to put into the project did not have an effective method of giving back an int[] datatype from the ArrayList

Additionally i made my own polyfill for the .toIntArray method if anyone is interested

public static int[] toIntArr(String filename) {
      ArrayList<Integer> ints = getIntData(filename);
      int length = ints.size();
      int[] values = new int[length];
      for(int i = 0; i < length; i++) {
          values[i] = ints.get(i);
      }
      return values;
  }

i know this solution probably isn’t the most ideal since it’s supposed to be included in the course but i hope this solution helps rectify why it wasn’t working

Varrience

1 Like

@jeff.rhodes - Thank you for posting this issue to the forum. I have reported it to the code.org support group. I will post an update once I know the issue is resolved and/or being addressed.

1 Like

Hi @jeff.rhodes ,
Sylvia will probably hear back more details from support@code.org, but my understanding of the FileReader class is that it is a hidden helper class, and will not work on levels that don’t have it loaded into the background.

A work around could be to use the 1 day project lesson for Unit 4 if you wish to also use the theater, or use the 1 day project lesson for Unit 3 if you just want a console.

Best,
Lindsay

2 Likes

Greetings all,

This actually looks to be an issue with the size of one of the integers in the Sales.txt file.

Since this number is above the max size of an int in Java, it causes the while() loop to terminate prematurely within FileReader.

While FileReader is technically a helper class (and is hidden by default on many of the levels on which it is used), it can also be included explicitly as a class file within your programs.

Cheers all (and happy holidays!)
Erik

2 Likes

Thanks for all your help everyone, I really appreciate it!

@erik_dillaman
Thanks for posting an update.