Lesson A2
Next: Class StructureLesson Overview:
In Lesson 1 you learned how to create and use objects to draw a partial house. The object types you used were:
SketchPad
DrawingTool
Color
All of the work was done in a single main() method. This is not good design because the components of the house were hard-coded and not reusable. For example, it's likely that if you wanted to have two windows on your house that you copied the code and modified the numbers to draw the second house. This repeat of code would be avoided if you had a separate Window class and you could just create two Window objects in two locations.
In this lesson you will learn how to create your own classes to define custom objects like a Window or Door. Doing so will make your overall program much more powerful because you'll be able to create many Windows or Doors from the same blueprint. Re-usability is one of the key features of Object-Oriented Programming.
An outline of the attributes and behaviors that is needed in a prospective class.
Statements in your program that Java ignores. They add clarity to your code.
A method with the same name as the class, used during object creation to initialize the starting state of an object.
A class that contains the main() method in your program.
A Java keyword instructing the compiler to retrieve a specific class.
The entry point of every Java application. Every Java application needs at least one main() method.
A Java keyword that creates an instance of a class from its constructor.
A group of similar types of classes, interfaces and sub-packages "packaged" together.
The Unified Modeling Language. A standardized modeling language used to visualize systems. Used in class diagrams.