- Objects
- Classes
- Inheritance
-
Programming in Java on Your Computer - Classes and Objects in BlueJ
- Trying out Code in BlueJ
- The Code for Creating and Using Objects
- Source Code and Methods
- Accessors and Mutators
- Constructor Code
- Scope
- Inheritance
-
BlueJ Review - Class Code
- Simple Debugging
- Interactive Picture
- Refactoring Code with Inheritance
Classes
Premium Content - Free Preview
Cars in the real world are rarely custom-made. Instead a blueprint is created for a specific car, such as the Toyota Camry, and then thousands of cars can be created based on it. Each Camry consists of the same components, but can have different details "filled-in". For example, one car might be blue and have a sunroof, while another car might be black and have leather seats.
Similarly, when programming, you do not need to custom-code each object on its own. Instead, you can create Classes as a "blueprint" for each object. In a racing game you can create a Class Racecar
and then create different instances of cars within the game. (Each instance of the Class Car is also known as a Car Object.) So player1
and player2
can each have their own instance of Racecar
which might be called racecar1
and racecar2
. While each car will have the same overall structure and components, they can have different values for their variables, for example:
End of Free Content Preview. Please Sign in or Sign up to buy premium content.
Comments
David
Mar 18, 8:09 AMblueprint -||- blackprint
thales
Jul 8, 8:38 AMyou used || very good :-)