U2L3 - Parameterized Constructors - Level 7C - Program runs, test fails

Hello code.org community, I know we are all busy this time of year but I would sincerely appreciate anyone who has the time to help. The problem:

Student attempting to complete U2L3 - Parameterized Constructors - Level7C. His program compiles successfully after completing all the tasks, but when the student tries to use the “test” function, the first task is reported as failed. Relevant code/console log:

public Planet (String aName, int whatNumMoons, boolean doesHasRingSystem) {
name = aName;
numMoons = whatNumMoons;
hasRingSystem = doesHasRingSystem;

[JAVALAB] Running level tests…

:heavy_multiplication_x: Planet.java Test > Write a parameterized constructor to assign values for name, numMoons, and hasRingSystem => FAILED
The constructor should specify a boolean parameter to assign a value to hasRingSystem.
==> expected: but was: (PlanetTest.java:45)
:heavy_check_mark: Planet.java Test > Write a parameterized constructor to assign values to name and numMoons => SUCCEEDED
:heavy_check_mark: Planet.java Test > Assign specific values to the name, numMoons, and hasRingSystem instance variables => SUCCEEDED
:heavy_check_mark: Planet.java Test > Assigns specific values to name and numMoons and a default value to hasRingSystem => SUCCEEDED

Link to a remix of the assignment, but the test feature isn’t available in the remix (have to copy/paste to level 7C in unit2 Lesson 3).

A couple of these failed tests have came up in this unit. Unit 2: Lesson 4: This Keyword has the same issue. When I see an issue like this I send them a ticket via support@code.org

I encourage you to do the same!


I reported it to code.org/support, Andrew told me to post here =)

1 Like

@a112032 - I used my teacher account to run the program with your students code. It compiled correctly for me. You might want to check that the rest of the code has been written correctly. I used the “For Teacher Only” link on that level to access the Code.org Example. I copied the entire code and then modified it to include your student’s parameterized class. Here’s the results that I got.

Let us know if this helps. Thanks for posting to the forum!


Hey @a112032, Thank you so much for posting your question to the forum. When I copied and pasted your code into the lesson I got the same error you did. I think I have a solution tho. Swap the order of your constructors. This is how I got it to work:

The way you have it, the two argument constructor is first and the three argument constructor is second. The documentation has it switched. I don’t know how it doesn’t pass the test unfortunately :(. Because you do have working code, just not in the order the tests want it to be.

I’ve come across this with some of my students too. They will show me working code that is not passing tests. It can be frustrating for the student (and myself) to not find the solution that would satisfy the tests. How did you address this with the student?


1 Like

@sylvia.wood Awesome, thanks. This does work, and it’s a clever way to solve the problem, I think the student would be satisfied with this explanation.

@sam_stafford This fix makes sense. I suspected something like this (but not exactly this) because I’ve helped the students fix a few of these previously (on another level, a test failed because Boolean had a capital B).

I agree it can be frustrating, but not as frustrating as teaching AP CSA without all the invaluable resources that code.org provides for free. As for how I addressed it - I explained, as I understand it (and I could be wrong), that this is a new feature for code.org and tried to relate it to the debugging process/writing code for unexpected user input (which they are learning about in U2L8/9). Then I told him I’d email customer support, and I showed him the response from code.org/these forums.

Thank you all for helping, I will try to pay it forward in the future. (I’ve already been bug reporting things as I find them).

You guys rock! Good vibes for the rest of the year.


@a112032 - Thanks for contributing to the forum. We are here to help each other.

1 Like

I’m having this error:

I’ve even deleted my work and copied and pasted the solution code into my workspace, and I run into the same error. I have the constructors ordered in the “right way” as described above.

Hi, I am not exactly sure what is happening. I would defer to any of the people who helped me solve this before, but I would also be happy to help. Could you post a link to a remix of the project in question?

1 Like

@julie.kirkpatrick - Hi Julie, we would be happy to help. It would be helpful if you could post the original code that resulted in the error. Also, have you tried using the sandbox in Lesson 16 to verify this error?

Hi @julie.kirkpatrick and teammates following this thread. I am also curious to see your code @julie.kirkpatrick because when I run my solution, and the exemplar solution, I get the following:

[JAVALAB] Program completed.
[JAVALAB] Connecting...
[JAVALAB] Compiling...
/PlanetTest.java:37: error: cannot find symbol
    String actualConstructor = ConstructorsHelper.findConstructorWithParameters(planetConstructors, 3, "String", "int", "boolean");
  symbol:   method findConstructorWithParameters(java.util.ArrayList<java.lang.String>,int,java.lang.String,java.lang.String,java.lang.String)
  location: class ConstructorsHelper
/PlanetTest.java:49: error: cannot find symbol
    if (ConstructorsHelper.hasConstructor(Planet.class, String.class, int.class, boolean.class)) {
  symbol:   method hasConstructor(java.lang.Class<Planet>,java.lang.Class<java.lang.String>,java.lang.Class<java.lang.Integer>,java.lang.Class<java.lang.Boolean>)
  location: class ConstructorsHelper
/PlanetTest.java:50: error: cannot find symbol
      Planet testPlanetThreeParameters = (Planet) ConstructorsHelper.createInstance(Planet.class, "Jupiter", 79, true);
  symbol:   method createInstance(java.lang.Class<Planet>,java.lang.String,int,boolean)
  location: class ConstructorsHelper
/PlanetTest.java:73: error: cannot find symbol
    String actualConstructor = ConstructorsHelper.findConstructorWithParameters(planetConstructors, 2, "String", "int");
  symbol:   method findConstructorWithParameters(java.util.ArrayList<java.lang.String>,int,java.lang.String,java.lang.String)
  location: class ConstructorsHelper
/PlanetTest.java:84: error: cannot find symbol
    if (ConstructorsHelper.hasConstructor(Planet.class, String.class, int.class)) {
  symbol:   method hasConstructor(java.lang.Class<Planet>,java.lang.Class<java.lang.String>,java.lang.Class<java.lang.Integer>)
  location: class ConstructorsHelper
/PlanetTest.java:85: error: cannot find symbol
      Planet testPlanetTwoParameters = (Planet) ConstructorsHelper.createInstance(Planet.class, "Mars", 2);
  symbol:   method createInstance(java.lang.Class<Planet>,java.lang.String,int)
  location: class ConstructorsHelper
[EXCEPTION] We couldn't compile your program. Look for bugs in your program and try again.
[JAVALAB] Program completed.

I have emailed support@code.org about this and I’m hoping others will do the same. I think that if more people report it will get bumped up the priority stack. Thanks for posting to the forum. It only makes our comunity, and curriculum better!


Unit 2 Lesson 3 Level 7: I had exactly the same issue with the test failing and I reviewing the code for most of my students. I told them to put a private comment to me in Google Classroom so I know that I checked it and I can give them credit.