Saturday, December 14, 2013

Example 1.1 CharStack Class

//CharStack.java
public class CharStack { //Class name
// Class Declarations
// Fields:                      (1)
private char[] stackArray; //The array implementing the stack.
private int topOfStack; // The top of the stack

//Constructor: (2)
public CharStack(int capacity) {
  stackArray = new char[capacity];
  topOfStack = -1;
}

//Methods: (3)
public void push(char element) {stackArray[++topOfStack] = element; }
public char pop() {return stackArray[topOfStack--];}
public char peek() {return stackArray[topOfStack];}
public boolean isEmpty() {return topOfStack < 0; }
public boolean isFull() {return topOfStack == stack.Array.lenght -1;}
}

A PROGRAMMERS GUIDE TO JAVA CERTIFICATION: Comprehensive Primer (3rd Edition)

Learning to Program Eclipse Java

Programs need not be made from scratch. Especially in Object Oriented Programming. The example given to you as you learn are used because of their relevance. That is what makes them such pervasive examples. They should be collected and treated like gold, because that is what they are. They are given to you on a silver platter, take advantage.

Your Drills in mastering this subject is comprised of examining and reexamine the examples you collect. Know them inside and out and synthesis them. In other words put them together in various combinations to create an entirely new program. 

Regardless of whether or not you are you are currently doing development, you should always be programming for programming's sake. This idea is adopted from the development of mathematics. Consider that programming is the logical evolution of mathematics.

It is best to have you example laid out in front of you as you read or are listening to the instructor. That way you can look at is as it is being explained to you. This is a big help