Greetings!
This is a summary of what we covered in class today. The three major object oriented programming concepts are: inheritance, polymorphism, and encapsulation.
(1) I
nheritance: ICA is a superclass (or parent) for Class2013, Class2012, Class2011, and Class2010 (which are subclasses or child classes). Each of the classes has attributes which describe the class. For example, the parent class of ICA has attributes of Teachers, Uniform, Mascot Sports, Classes, Colors, and Students. The child classes inherit those attributes.
(2)
Polymorphism: However, the child classes may have attributes which override the inherited classes as well as additional attributes. For example, the seniors (Class2010) and juniors (Class2011) each have attributes of class sweater which override the regular burgundy sweater inherited as part of the uniform from the parent, ICA. They also have class ring attributes which do not exist in the parent, ICA.
(3)
IS-A and HAS-A: The relationship between parent and child classes is called an IS-A relationship. For example, Class2010 IS-A ICA, and Class2011 IS-A ICA. The classes have attributes which describe the class. The relationship between a class and its attributes is a HAS-A relationship. For example, we would say that Class2010 HAS-A class sweater, and Class2011 HAS-A class ring. To summarize: HAS-A refers to attributes; IS-A refers to the relationship of subclass to superclass. Having an IS-A relationship implies that the subclass inherits attributes from the superclass. In our Java programs, attributes often become variable names. Attributes may also become names of methods.
(4)
Instantiating: We can talk about next school year's incoming freshman, Class2013. We know they will inherit attributes from the parent class, ICA, such as Teachers, Uniform, Mascot, Sports, Students, Colors, and Cafeteria. We know that they will have additional attributes of Big Sisters, Orientation Day, Frosh Folly, Colors, Song, and Welcome Dinner. However, we don't yet have any students in the Class of 2014. We don't have "real" students yet. When we do, we instantiate an object in Class2014. Until that time when we have an actual person in Class2014, the Java class of Class2014 is just a template. Another example is a recipe for Brownies. The recipe is the template, the description of the brownie. Once we make and bake the brownies, we instantiate them. We make them "real." Just like you can't eat a brownie until you actually make the recipe, we cannot instantiate a class until we have a real object in the class created by using the new Java command. An example of using the new command to instantiate an object is the following line we used in our Parrot class:
KeyboardReader new rr;
The keyword new creates space in the memory of a computer. So, a brief survey of computer components:Memory - is like our memoryCentral Processor Unit or Microprocessor - is like our brainInput/Out Devices - are like our senses. Examples of Input devices are webcam, keyboard, mouse, and microphone. Examples of Output devices are speakers and monitors. Hard drives (which is extra storage in addition to Memory), touch screens, and flash disks are example of Input and Output devices. When Java programs run, space is created for them in memory. When we use the Java command new to instantiate an object, a spot in the space reserved for Java programs is created in the computer's memory.
(5)
Encapsulating: Hiding the details. For example, we don't care about the electronics of how our cell phones are able to call other people. We just want to call home or our friends. Using our ICA example, moms who come to the Mother-Daughter tea just come to enjoy the event. All of the preparation details are hidden from them so they may relax and enjoy.