Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

Java

hamsternation
hamsternation
26,615 Points

Filtering High Scores submission failing

I think there's an issue with all these Gradle based code submission tasks. I'm pretty certain my code itself is correct, but every time I try to submit the code to these challenges, it says:

"Oh no! We encountered an error with your last submission."

My code:

  public static void printBurgerTimeScoresDeclaratively(List<Score> scores) {
    // TODO: Open a stream off of scores and filter "Burger Time" scores that are larger than 20,000
    // TODO: Print out those scores using the forEach method off of the Stream
    scores.stream()
      .filter(score -> score.getGame().equals("Burger Time"))
      .filter(score -> score.getAmount() >= 20000)
      .forEach(System.out::println);
  }

my output locally in my IDE:

2:59:40 PM: Executing ':Main.main()'...

:compileJava
:processResources
:classes
:Main.main()
There are 3549 total scores. 

Imperative Burger Time Scores Greater than 20,000
Score{game='Burger Time', measuringUnit='NTSC - Points', amountAsString='2,078,500', player='Matthew Grimm', platform='Nintendo Entertainment System'}
Score{game='Burger Time', measuringUnit='NTSC - Points', amountAsString='225,650', player='Christopher Jedrzejek', platform='Nintendo Entertainment System'}
Score{game='Burger Time', measuringUnit='NTSC - Points', amountAsString='73,400', player='Patrick Scott Patterson', platform='Nintendo Entertainment System'}
Score{game='Burger Time', measuringUnit='NTSC - Points', amountAsString='59,550', player='Eric Cummings', platform='Nintendo Entertainment System'}
Declarative Burger Time Scores Greater than 20,000
Score{game='Burger Time', measuringUnit='NTSC - Points', amountAsString='2,078,500', player='Matthew Grimm', platform='Nintendo Entertainment System'}
Score{game='Burger Time', measuringUnit='NTSC - Points', amountAsString='225,650', player='Christopher Jedrzejek', platform='Nintendo Entertainment System'}
Score{game='Burger Time', measuringUnit='NTSC - Points', amountAsString='73,400', player='Patrick Scott Patterson', platform='Nintendo Entertainment System'}
Score{game='Burger Time', measuringUnit='NTSC - Points', amountAsString='59,550', player='Eric Cummings', platform='Nintendo Entertainment System'}

BUILD SUCCESSFUL

Total time: 1.338 secs
2:59:41 PM: Execution finished ':Main.main()'.

This happens to the for each challenge and the using method references challenges as well!

@Craig Dennis

Andrew Stevens
Andrew Stevens
11,007 Points

I am having the same issue hamsternation did you ever pass this? can't see anything obviously wrong with your code or mine.

public class Main {

  public static void main(String[] args) {
    ScoreService service = new ScoreService();
    List<Score> scores = service.getAllScores();
    System.out.printf("There are %d total scores. %n %n", scores.size());
    System.out.println("Imperative Burger Time Scores Greater than 20,000");
    printBurgerTimeScoresImperatively(scores);
    System.out.println("Declarative Burger Time Scores Greater than 20,000");
    printBurgerTimeScoresDeclaratively(scores);
  }


  public static void printBurgerTimeScoresImperatively(List<Score> scores) {
    for (Score score : scores) {
      if (score.getGame().equals("Burger Time") && score.getAmount() >= 20000) {
        System.out.println(score);
      }
    }
  }

  public static void printBurgerTimeScoresDeclaratively(List<Score> scores) {
    // TODO: Open a stream off of scores and filter "Burger Time" scores that are larger than 20,000
  scores.stream()
      .filter(score -> score.getGame().equals("Burger Time"))
      .filter(score -> score.getAmount() >= 20000)
    // TODO: Print out those scores using the forEach method off of the Stream
      .forEach(System.out::println);

  }

}