Jump to content
  • Advertisement
Sign in to follow this  
  • entry
  • comments
  • views

An OOP Approach Chapter 1 02-14-06

Sign in to follow this  


Welcome to this great lesson of Java Programming. In this lesson, I will discuss what OOP (Object Oriented Programming) is, the difference between a class and an Object. Classes and Objects, Messages and Methods, and how to compile and Run a Program.

* Hardware
* Software
* Object-Oriented Programming

Ok let's begin Smiley!!

Object-Oriented Programming (OOP) represents an attempt to make programs more closely model the way people think about and deal with the world. In object-oriented programming, a program consists of a collection of interacting objects. The world in which we live is filled with objects. Java is an OOP programming language and in this lesson we will go over what OOP is all about.

Ok, Something that is intangible means that you can not touch it. On the opposite side of that, something that is tangible means that you can touch it. But what does this have to do with programming? Well, in the computer industry you have what is called hardware and software. First lets begin with hardware, or the tangible parts of the computer. Say for instance you record a movie onto a cassette tape. The actual tangible part of the movie would be the cassette tape, but the intangible part of the tape would be the movie. You can think of this analogy like this: the movie being the softaware and the tape being the hardware. The good thing about the computer system is that it combines tangible objects, hardware, with conceptual components, called software. Here's another analogy to think about: What if you had the book called "The Lord of The Rings, The Hobbit," and you tore it up into shreds and put it through a shreding machine. Have you destroyed the book? If your answer was yes then you are incorrect because you did not destroy the intangible book but you actually destroyed the book itself. Make sense? Anyways, it is very important to understand what tangible and intangible means. Let's take a look at this program to give you a better understanging.

* DrawSquare This class will create a piece of paper and a pencil,
* place the pencil on the paper and then draw a square 100 units on
* each side.
import apcslib.*;
import java.awt.Color;

public class DrawSquare
* The main program for the DrawSquare class
* @param args The command line arguments (not used)
public static void main(String[] args)
//Instantiating Variables
DrawingTool pencil;
SketchPad paper;
DrawingTool eraser;

//Declaring Variables
paper = new SketchPad(1900, 1900);
pencil = new DrawingTool(paper);
eraser = new DrawingTool(paper);

// draw the square


Now, let's break down each and every little aspect of this code. An object in programming is an abstraction for a real-world object. For example, a drawing tool is an attempt to model the attributes and behaviors of a pencil or pen, etc. As a programmer, we need some way of knowing what is the "blueprint" in the code. We call the blueprint of the code, the class. A class in Java programming, varies from state to state meaning, that it can be used many times to make many different things such as a stamp. Each imprint is an object and each one has its own individual properties such as "size" and "position." Different stampings may have different characteristics, even though they were all made with the same rubber stamp.

(not complete). I am writing this on the day of February 14, 2006 at 10:44PM and now I must go to bed but I hope you all enjoy my journal on Java Programming
Sign in to follow this  


Recommended Comments

Welcome to journal land! Here is some + to get you started and hopefully bring you back to post more.

Share this comment

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!