Snake (Part 4/20)

  • 3
  • Locked
One of the game objects will be an apple. Create an Apple class and make it inherit the GameObject class. To represent an apple on the playing field, you could paint cells containing apples any particular color. Or you could draw some apple-looking symbol in the cell. Let the Apple class store thi
You can't complete this task, because you're not signed in.
Comments (11)
  • Popular
  • New
  • Old
You must be signed in to leave a comment
24 September 2020, 10:34
I keep failing to pass the following requirement. Can anyone give me some guidance? "The draw(Game) method must call the setCellValueEx(int, int, Color, String, Color, int) method on a Game object with the following arguments: x, y, Color.NONE, APPLE_SIGN, <color of the apple>, 75. (Replace <color of the apple> with a color you like, for example, Color.GREEN)."
Level 41
25 September 2020, 09:47
Please post your question with the attached solution in the section Help.
Level 15 , United Kingdom
19 September 2020, 20:56
can someone explain to me why apple.draw(this) works? I mean I get that apple.draw(apple) is wrong since apple is of type Apple while draw(Game) expects Game type but why does "this" work? I thought "this" refers to the object that's calling the method which is apple so "this" should be of type Apple too?
Killer ID
Level 17 , Shenzhen, China
13 July 2021, 13:46
The same question for me...😬
Tara Davies
Level 1 , Singapore
5 March 2022, 03:52
Hi! No, the 'this' keyword refers to the class.
Sakka Mouid
Level 19 , Hannover, Deutschland
22 April 2022, 16:36
@Tara this is the first time i see that "this" refers to a class . I used to know that it refers always only to the current object
Level 19
14 September 2022, 15:43
"this" refers to the object of SnakeGame class, because SnakeGame inherit Game class,so "this" can also call the setCellValueEx() method.
Stephan E.
Level 10 , Stuttgart, Germany
13 March 2020, 12:49
Which Project Language Level must be choosen in IntelliJ Idea or which SDK ?
Level 41
16 March 2020, 07:00
shabarish kumar
Level 20 , Hyderabad, India
21 July 2019, 04:53
Hi team, We are unable to meet the below requirement. Could you please elaborate about the same. The draw(Game) method must be called on the created apple. Pass this to the method.
Level 22 , Iasi, Romania
14 June 2021, 13:46
it can be a little confusing, the right sentence i think will be: Pass 'this' to the method.