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!

2 Likes

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!

2 Likes

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?

Best
-Sam

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.

3 Likes

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

1 Like