Due by the end of today by midnight
This program was produced by an AI as a response to the experiment is L00. It was generated from the comment at its start. (I also made some further suggestions and a couple of minor adjustments.)
In terms of completing the task, it is excellent. There are cosmetic differences, for sure, but I think it actually looks a bit nicer than what I made for the experiment.
Nevertheless, as an example of programming, it is not great. I gave this program to GitHub's gpt-5-mini and asked it to "[a]nalyze this file for poor programming practices." It came up with this report:
I'd like to add that it's not just the numbers that should be extracted into constants. The colours should also be listed at the top (with appropriate names) to make them easy to modify.
In the rest of this lab, you are going to fix some of these problems.
Please don't fix more than what's shown below before you submit. I'll be looking for the indicated changes, and having more changes to look thru will just complicate my job.Do feel free to try to fix more problems later, on your own (with or without the help of AI).
As is good programming practice, you should test your changes as you make them. Don't try to make all the changes below before testing them. That way lies confusion and despair!
new Color
and create a constant for that colour.
Give it an appropriate name.
Use the name in the code.
You do not need to replace the uses of
Color.BLACK.
Black is being used for the edges of the cards
and the numbers.
It's unlikely anyone would want to change those colours.
new Random
with a reference to a shared instance.
paintCentre.
NOTE that,
other than the lines that declare and set
x, y, width and height,
the method paintCentre
has exactly
the same code as paint:
g to Graphics2D.
setRenderingHint.
Also note
that
x, y, width and height,
(along with g)
are exactly the values that paint needs
in order to do its job.
Update the code for paintCentre
so that it
calls paint
with the correct arguments
to get the card drawn where it's supposed to be drawn.
Submit this/these files: