Create PT - Java's repaint() used for abstraction

apcsp
createtask

#1

I have a student who is making a snake game in Java. He has a paint() function that Java creates and uses for any program. He adds all of his visual code there. In order to call that paint function Java uses repaint() so that it can continuously redraw the visuals. He calls this repaint() function, that ultimately calls paint(), multiple times in his code.

Can the paint() function be used for his abstraction? I’m just concerned with the function name and call being different so they may not think it’s legit.

Thanks,
Dave


#2

Hey @dhust it’s hard to say without more experience with that interface but in general if a student created a function and wrote all the code themselves it’s likely a good candidate. If the student is using an abstraction (function) created by the environment then even if they added their own code they’re not really doing the abstracting themselves and our read of the guidelines are that that would not count.

My recommendation would be to have students create the abstraction entirely from scratch. If you have more questions you might also consult the Create PT Survival Guide in this lesson where we have some activities to help students better understand what we believe will and will not count.

Hope that helps!


#3

Hmm. Here’s the basic setup of what he’s doing.

function paint() {
  // do stuff
}

function this() {
  // do other stuff
  paint()
}

function that() {
  // other stuff
  paint()
}

In Java, instead of calling paint() they tell you to use repaint() because it not only calls paint() but also automatically does other stuff like clear the screen and refresh things again - every second or so.

So then his code looks more like,

function paint() {
  // do stuff
}

function this() {
  // do other stuff
  repaint()
}

function that() {
  // other stuff
  repaint()
}

Is that ok since he made all the // do stuff himself and he’s still technically calling his function paint() from other places?

Thanks.


#4

repaint() will not get him the credit for abstraction because it is a standard java function. However, if he can include function calls to this() and that() within his do stuff body of the paint function, that protocol should get him the abstraction credit.
My assumption is that this is a similar program to the one he is doing for his Create Task. I say this because we are not allowed to give students assistance on their program to be submitted.