Hi! I'm taking a course on JAVA, and i dont understand what a class is. Why do we have them and what do they do? Can someone help me please!
Stacey Warren - Expert brainly.com
Hey! We 've verified this expert answer for you, click below to unlock the details :)
At vero eos et accusamus et iusto odio dignissimos ducimus qui blanditiis praesentium voluptatum deleniti atque corrupti quos dolores et quas molestias excepturi sint occaecati cupiditate non provident, similique sunt in culpa qui officia deserunt mollitia animi, id est laborum et dolorum fuga.
Et harum quidem rerum facilis est et expedita distinctio. Nam libero tempore, cum soluta nobis est eligendi optio cumque nihil impedit quo minus id quod maxime placeat facere possimus, omnis voluptas assumenda est, omnis dolor repellendus.
Itaque earum rerum hic tenetur a sapiente delectus, ut aut reiciendis voluptatibus maiores alias consequatur aut perferendis doloribus asperiores repellat.
I got my questions answered at brainly.com in under 10 minutes. Go to brainly.com now for free help!
The term template applies. This is in the Java documentation:
As it says there, it is like a blueprint for making objects.
Lets take a playing card from a dec of cards. It has a certain shape that all the cards will have. It has a suit, there are only four, and a value, of which there are thirteen. If you need to make just the standard cards, it will always be within those limits. For a computer game of cards, you might use the size to define how it will be drawn on the screen. That basic allocation of size will be the same for all cards. They template for the cards would have that and places to store the suit and value. This template would be a class file for the cards.
so would each type of card have its own template?
Generally, no. If it is a deck of cards, the template would be for a card, which is enough.
I made a space game for a school project once. I made a template for objects in space. Then, I made a child of this template that was for asteroids and used that scild template to make lots of asteroids. In this way, I wrote the fact that things needed an x/y positon, alive/dead, and associated image once. The asteroids only needed that much, as did missiles. The player also needed a little more, like total number of lives remaining and speed. oops... yah, asterpoids also had speed, it went up each level... anyhow, it made it so I rewrote the code less because each class was a sub class of the object class and inherited the basic properties needed.